Guido van Rossum wrote:
> Can we skip ahead to considering how to implement this? I can think of two
> approaches: either hack the lexer to special-case a newline followed by a
> period (which currently can never start a line), or redesign the syntax to
> allow NEWLINE INDENT ‘.’ ......... NEWLINE ‘.’ ............ DEDENT at the
> end of an expression. Both have pros and cons.
> Discuss how this allows for certain typos to pass as valid syntax.
IIRC, BCPL's compiler would continue and expression on the next line if a line
ended with an operator. E.g.:
x = a +
b
would parse like
x = (a +
b);
(I think this was a bit more general - if a line didn't end with ";", the
parser would try adding a ";" and if that failed to parse, it would continue to
the next line.)
This leads result in a different style for method-chaining:
y = x.rstrip("\n").
split(":")[0].
lower()
... and if you don't like ending lines with a ".", you could always add a
parenthesis:
y = (x.rstrip("\n")
.split(":")[0]
.lower())
[I wonder why C didn't adopt BCPL's convention for eliding semi-colons? ...]
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/A344DHD4YD25DQFM2OYBNKU63HTHO4FN/
Code of Conduct: http://python.org/psf/codeofconduct/