On Thu, Aug 29, 2019 at 08:17:39PM +1200, Greg Ewing wrote:
> stpa...@gmail.com wrote:
> 
> >    re'a|b|c'  --becomes-->  (locals()["re~"])("a|b|c")
> >    2.3f       --becomes-->  (locals()["~f"])("2.3")
> 
> How does one get a value into locals()["re~"]?

I don't think that stpa...@gmail.com means that the user literally 
assigns to locals() themselves. I read his proposal as having the 
compiler automatical mangle the names in some way, similar to name 
mangling inside classes.

The transformation from prefix re to mangled name 're~' is easy, the 
compiler could surely handle that, but I'm not sure how the other side 
of it will work. How does one register that re.compile (say) is to be 
aliased as the prefix 're'? I'm fairly sure we don't want to allow ~ in 
identifiers:

    # not this
    re~ = re.compile

I'm still not convinced that we need this parallel namespace idea, even 
in a watered down version as name-mangling. Why not just have the prefix 
X call name X for any valid name X (apart from the builtin prefixes)? I 
still am not convinced that is a good idea, but at least the complexity 
is significantly reduced.


P.S. stpa...@gmail.com if you're reading this, it would be nice if you 
signed your emails with a name, so we don't have to refer to you by your 
email address or as "the OP".

-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/W45RVSWEBM22EXZQ4DGE5KP7WNIRPWCG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to