On Wed, Jun 23, 2021 at 8:30 AM Soni L. <fakedme...@gmail.com> wrote:
>
>
>
> On 2021-06-22 5:54 p.m., Chris Angelico wrote:
> > On Wed, Jun 23, 2021 at 6:41 AM Soni L. <fakedme...@gmail.com> wrote:
> > > It would have local scope, similar to uh... locals. Y'know how locals
> > > are just sugar for locals()['foo'] and stuff? Yeah.
> >
> > Not really, no, they're not. :) The dictionary returned by locals()
> > isn't actually an implementation detail of local name lookups.
>
> It's... part of the language. Not an implementation detail. The
> dictionary returned by locals() is an inherent part of local name
> lookups, isn't it?

No, it's not. Most definitely not.

https://docs.python.org/3/library/functions.html#locals

> > Have you put any thought into how you would deal with the problem of
> > recursive __dot__ calls?
>
> Let it recurse!
>
> Globals and locals don't go through __dot__, so you can just... use
> them. In particular, you can always use getattr(), and probably should.
> Or even set __dot__ to getattr inside it, like so:
>
> def __dot__(left, right):
>   __dot__ = getattr
>   foo.bar # same as getattr(foo, "bar") because we set (local) __dot__
> to getattr above

I can't actually pin down what I'm averse to here, but it gives me a
really REALLY bad feeling. You're expecting every attribute lookup to
now look for a local or global name __dot__ (or, presumably, a
nonlocal, class, or builtin), and do whatever that does. That seems
like a really effective foot-gun.

Have you actually tried designing this into a larger project to see
what problems you run into, or is this something you've only
considered at this trivial level?

ChrisA
_______________________________________________
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/YOPTCIYV4GSW3N7EA7KPLJBKNVSNANXZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to