Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Greg Ewing
Steven D'Aprano wrote: So instead of having two classes of identifiers - those that can be used anywhere; - those that can only be used as dotted names; you would have two classes of keywords: - those that cannot be shadowed; - those that can be shadowed. Yes. But we would always recommend

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Guido van Rossum
I hereby withdraw the idea. -- --Guido van Rossum (python.org/~guido) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Steven D'Aprano
On Mon, May 14, 2018 at 01:28:51PM +1200, Greg Ewing wrote: > Redefining the existing keywords could perhaps be forbidden > if you really want to protect people from shooting themselves > in the kidneys this particular way. So instead of having two classes of identifiers - those that can be

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Jacco van Dorp
While I understand the attraction, I think the clarity cost might be to high. If it's a pain to explain it to an IDE, it's an even bigger pain to explain it to people new to the language. ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Paul Moore
On 15 May 2018 at 11:07, Antoine Pitrou wrote: > On Tue, 15 May 2018 21:51:20 +1200 > Greg Ewing wrote: >> Ethan Furman wrote: >> > Part of the point of the proposal is to be able to use existing keywords >> > (at least, I thought it was). >> >>

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Antoine Pitrou
On Tue, 15 May 2018 21:51:20 +1200 Greg Ewing wrote: > Ethan Furman wrote: > > Part of the point of the proposal is to be able to use existing keywords > > (at least, I thought it was). > > Mainly it's so that *new* keywords can be added to the language > without

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-15 Thread Greg Ewing
Ethan Furman wrote: Part of the point of the proposal is to be able to use existing keywords (at least, I thought it was). Mainly it's so that *new* keywords can be added to the language without breaking old code. Nobody is going to want to turn one of the currently existing keywords into a

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-14 Thread Terry Reedy
On 5/14/2018 6:58 PM, Greg Ewing wrote: Terry Reedy wrote: the first two 'and's in "a and b.and # and error" are tagged. To not tag the second would require full parsing, That particular case could be handled by just not colouring any word following a dot. OK, more parsing, even if not

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-14 Thread Greg Ewing
Terry Reedy wrote: the first two 'and's in "a and b.and # and error" are tagged. To not tag the second would require full parsing, That particular case could be handled by just not colouring any word following a dot. Some other situations might result in false positives, but there are cases

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-14 Thread Ethan Furman
On 05/13/2018 10:57 PM, Greg Ewing wrote: Rob Cliffe via Python-ideas wrote: If you forbid redefining keywords, you remove the whole point of this proposal: I mean the keywords that are in the language as of now. There will never be a need to redefine those, since no current code uses them

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-14 Thread Tim Peters
[Terry Reedy ] > ... > The impact on real-time syntax coloring should be considered. An re-based > colorizer, like IDLE's, tags every appearance of keywords outside of strings > and comments, syntactically correct or not. For instance, the first two > 'and's in "a and b.and #

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-14 Thread Terry Reedy
On 5/13/2018 2:19 PM, Guido van Rossum wrote: The idea I had (not for the first time :-) is that in many syntactic positions we could just treat keywords as names, and that would free up these keywords. This trades the simplicity of 'using a keyword as an identifier always fails

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-14 Thread Ed Kellett
On 2018-05-14 12:35, Rhodri James wrote: > On 13/05/18 19:19, Guido van Rossum wrote: >> The idea I had (not for the first time:-)  is that in many syntactic >> positions we could just treat keywords as names, and that would free up >> these keywords. > > I'm not familiar with the innards of the

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-14 Thread Rhodri James
On 13/05/18 19:19, Guido van Rossum wrote: The idea I had (not for the first time:-) is that in many syntactic positions we could just treat keywords as names, and that would free up these keywords. I'm not familiar with the innards of the parser and it's wy too long since I sat through

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Greg Ewing
Rob Cliffe via Python-ideas wrote: If you forbid redefining keywords, you remove the whole point of this proposal: I mean the keywords that are in the language as of now. There will never be a need to redefine those, since no current code uses them as names. -- Greg

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Nick Coghlan
On 13 May 2018 at 14:19, Guido van Rossum wrote: > As anyone still following the inline assignment discussion knows, a > problem with designing new syntax is that it's hard to introduce new > keywords into the language, since all the nice words seem to be used as > method names

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Carl Smith
As long as any new syntax allowed us to still reference the occassional thing in the older libraries that used newly reserved names, it would not come up that often, and would avoid the biggest cost of a whole new version. If `foo` was a reserved word, then this could be allowed... import

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Rob Cliffe via Python-ideas
On 14/05/2018 02:28, Greg Ewing wrote: Rob Cliffe via Python-ideas wrote:     def and(x, y):     return ... #   and(1,2)   #  Oops, SyntaxError.  Oh, I know:     globals()['and'](1,2)    # Works! If the rule I proposed for "import" were extended to "def" then and(1,2) would

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Rob Cliffe via Python-ideas
On 13/05/2018 19:19, Guido van Rossum wrote: As anyone still following the inline assignment discussion knows, a problem with designing new syntax is that it's hard to introduce new keywords into the language, since all the nice words seem to be used as method names in popular packages.

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Nathaniel Smith
On Sun, May 13, 2018 at 9:00 PM, Greg Ewing wrote: > Guido van Rossum wrote: >> >> Of course this would still not help for names of functions that might be >> imported directly (do people write 'from numpy import where'?). > > > Maybe things could be rigged so that if

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Carl Smith
New Python versions already use backwards incompatible syntax, but it has to be a strict superset so the new parser still parses old code. If a new Python version introduced syntax that would break old code, it would still work, so long as the parser knew which syntax the file contained, and was

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Greg Ewing
Rob Cliffe via Python-ideas wrote: def and(x, y): return ... # and(1,2) # Oops, SyntaxError. Oh, I know: globals()['and'](1,2)# Works! If the rule I proposed for "import" were extended to "def" then and(1,2) would work. The usual way of using "and" would no

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Greg Ewing
Elias Tarhini wrote: The thought of writing "operator.not" is appealing, but being forced to use *that* (with *from operator import not* being non-allowable) may not be. Under the proposal I made in my last post, "from operator import not" would be fine -- you just wouldn't be able to use the

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Greg Ewing
Guido van Rossum wrote: Of course this would still not help for names of functions that might be imported directly (do people write 'from numpy import where'?). Maybe things could be rigged so that if you use a reserved word as a name in an import statement, it's treated as a name everywhere

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Rob Cliffe via Python-ideas
On 13/05/2018 19:19, Guido van Rossum wrote: As anyone still following the inline assignment discussion knows, a problem with designing new syntax is that it's hard to introduce new keywords into the language, since all the nice words seem to be used as method names in popular packages.

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Tim Peters
[Guido] > ... > I should also mention that this was inspired from some messages where Tim > Peters berated the fashion of using "reserved words", waxing nostalgically > about the old days of Fortran (sorry, FORTRAN), which doesn't (didn't?) have > reserved words at all (nor significant whitespace,

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Nathan Schneider
Care would have to be taken in the grammar to avoid syntactic ambiguity. For example: x = 1 def not(x): ... if not - x: # Is this 'not' the keyword or the identifier? not (-x), or not minus x? ... Nathan On Sun, May 13, 2018 at 2:20 PM Guido van Rossum wrote: > As

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Rob Cliffe via Python-ideas
On 13/05/2018 19:19, Guido van Rossum wrote: As anyone still following the inline assignment discussion knows, a problem with designing new syntax is that it's hard to introduce new keywords into the language, since all the nice words seem to be used as method names in popular packages. (E.g.

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Elias Tarhini
Apologies for my initial response. Looks like I failed to expand the initial email fully, which would have shown me the following :) > Of course this would still not help for names of functions that might be imported directly (do people write 'from numpy import where'?). -- I do think the

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Brendan Barnwell
On 2018-05-13 11:19, Guido van Rossum wrote: As anyone still following the inline assignment discussion knows, a problem with designing new syntax is that it's hard to introduce new keywords into the language, since all the nice words seem to be used as method names in popular packages. (E.g. we

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Stephan Houben
Note that Javascript does something similar, in that reserved keywords are allowed in member access. var x = {if : 42}; console.log(x.if); Stephan 2018-05-13 20:42 GMT+02:00 Eric Fahlgren : > On Sun, May 13, 2018 at 11:20 AM Guido van Rossum > wrote:

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Chris Angelico
On Mon, May 14, 2018 at 4:19 AM, Guido van Rossum wrote: > The idea I had (not for the first time :-) is that in many syntactic > positions we could just treat keywords as names, and that would free up > these keywords. > ... > I should also mention that this was inspired from

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Elias Tarhini
I like it! The obvious question, though: How would "*from package import keyword*" be handled, if not simply by SyntaxError? Would *from package import keyword as keyword_* be allowed? In a similar vein, what would happen with stdlib functions like operator.not_? The thought of writing

[Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Guido van Rossum
As anyone still following the inline assignment discussion knows, a problem with designing new syntax is that it's hard to introduce new keywords into the language, since all the nice words seem to be used as method names in popular packages. (E.g. we can't use 'where' because there's numpy.where