Sujet : Re: Tabs As Syntax
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.os.linux.advocacyDate : 21. Mar 2024, 01:53:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <utfstp$1pfg9$2@dont-email.me>
References : 1 2
User-Agent : Pan/0.155 (Kherson; fc5a80b8)
On Wed, 20 Mar 2024 08:13:18 -0400, Chris Ahlstrom wrote:
The usage of spaces or tabs to determine statement scope is a great big
turnoff for me.
>
I don't subscribe to Guido's opinion on the visual ease of indentation.
There is redundancy in how most reasonable programmers write their
code; in conventional languages, where there are explicit
statement-bracketing symbols, the indentation (which the compiler
ignores) tends to follow these symbols anyway. That redundancy is a
useful check that the code means what you think it means.
Python does away with that redundancy, by making the indentation serve
as statement-bracketing as well. I think this is a mistake. However, I
restore the redundancy by adding “#end” lines (which the compiler
ignores). E.g.
def parse_headers() :
nonlocal content_type, content_type_opts
for keyword, value in scope["headers"] :
keyword = keyword.decode().lower()
if keyword == "content-type" :
content_type = value.decode()
elif keyword == "cookie" :
for item in value.decode().split(";") :
name, val = item.strip().replace(" ", "").split("=", 1)
cookies[name] = val
#end for
#end if
#end for
if content_type != None :
content_type, content_type_opts = \
multipart.multipart.parse_options_header(content_type)
content_type = content_type.decode()
content_type_opts = dict((k.decode(), v) for k, v in content_type_opts.items())
#end if
#end parse_headers
Another useful consequence is, I have custom Emacs commands defined to
jump between lines with matching indentation. This lets me navigate
quickly between the start and end of statement blocks. Without those
“#end” lines, it would not be so easy to find the ends of the blocks.