Sujet : Re: Python (was Re: I did not inhale)
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.shell comp.unix.programmer comp.lang.miscDate : 29. Aug 2024, 01:44:28
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240828163641.223@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-08-28, Keith Thompson <Keith.S.Thompson+
u@gmail.com> wrote:
Bart <bc@freeuk.com> writes:
On 28/08/2024 19:48, David Brown wrote:
But some of us devise (and, importanly, implement) languages of our
own and can be more vocal about misfeatures in others.
>
If I'm moving chunks of code around in a C or C++ program, from one
scope to another, I can get away with leaving the indentation as it is,
because all the compiler cares about is where the braces are. But I
*always* adjust the indentation to fit the code's new context.
>
Python's use of indentation to indicate scoping just means that I have
to do what I would have done anyway.
In a language with brackets or braces, the indentation can adjust itself
for you.
The proof of concept for this is the "parinfer" algorithm, for Lisp
languages. Someone came up with this a bunch of years ago and now
it's fairly widely implemented.
Parinfer creates a real-time link between indentation and parentheses.
It can be configured to infer one from the other: you can manually
control indentation and have parentheses magically appear and disappear
as needed, or you can control parentheses and have the code indent
itself.
Likely, a much more complicated version of the algorithm could work
for "C likes" and others. Maybe someone has done it by now? No idea.
There are some animated demos on the original home page, and maybe
elsewhere:
https://shaunlebron.github.io/parinfer/I use a somewhat poor but usable Vim implementation of this.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca