[Python-ideas] PEP 505 (None coalescing operators) thoughts
Guido van Rossum
guido at python.org
Tue Sep 29 05:11:00 CEST 2015
I would at least define different classes for the uptalk versions.
But my main complaint is using the parse tree as a spec at all -- it has
way too much noise for a clear description. We don't describe a < b < c by
first translating it to (Comparison(a, Comparison(b, c, chained=False),
chained=True) either: the reference manual uses a postfix * (i.e.
repetition) operator to describe chained comparisons -- while for other
operators it favors a recursive definition.
On Mon, Sep 28, 2015 at 7:22 PM, Random832 <random832 at fastmail.com> wrote:
> On Mon, Sep 28, 2015, at 17:48, Guido van Rossum wrote:
> > > Expr(
> > > value=Attribute(
> > > value=Attribute(
> > > value=Name(id='spam'), attr='eggs', uptalk=True),
> > > attr='cheese', uptalk=False))
> > >
> >
> > Hm, I think the problem is that this way of representing the tree
> > encourages thinking that each attribute (with or without ?) can be
> > treated
> > on its own.
>
> How else would you represent it? Maybe some sort of expression that
> represents a _list_ of attribute/item/call "operators" that are each
> applied, and if one of them results in none and has uptalk=True it can
> yield early.
>
> Something like...
>
> AtomExpr(atom=Name('spam'), trailers=[Attribute('eggs', uptalk=True),
> Attribute('cheese', uptalk=False)])
>
> For a more complex example:
>
> a?.b.c?[12](34).f(56)?(78)
>
> AtomExpr(Name('a'), [
> Attribute('b', True),
> Attribute('c', False),
> Subscript(12, True),
> Call([34], False),
> Attribute('f', False),
> Call([56], False),
> Call([78], True)])
>
> I almost sent this with it called "Thing", but I checked the grammar and
> found an element this thing actually maps to.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150928/8a5aa682/attachment.html>
More information about the Python-ideas
mailing list