On Wed, Aug 28, 2019 at 2:40 PM Andrew Barnert <abarn...@yahoo.com> wrote:
> > People can be trusted with powerful features that can introduce
> > complexity. There's just not a lot of point introducing a low-value
> > feature that adds a lot of complexity.
>
> But it really doesn’t add a lot of complexity.
>
> If you’re not convinced that really-raw string processing is doable, drop 
> that.
>
> Since the OP hasn’t given a detailed version of his grammar, just take mine: 
> a literal token immediately followed by one or more identifier characters 
> (that couldn’t have been munched by the literal) is a user-suffix literal. 
> This is compiled into code that looks up the suffix in a central registry and 
> calls it with the token’s text. That’s all there is to it.
>

What is a "literal token", what is an "identifier character", and how
does this apply to your example of having digits, a decimal point, and
then a suffix? What if you want to have a string, and what if you want
to have that string contain backslashes or quotes? If you want to say
that this doesn't add complexity, give us some SIMPLE rules that
explain this.

And make absolutely sure that the rules are identical for EVERY
possible custom prefix/suffix, because otherwise you're opening up the
problem of custom prefixes changing the parser again.

> Compare that adding Decimal (and Fraction, as you said last time) literals 
> when the types aren’t even builtin. That’s more complexity, for less benefit. 
> So why is it better?
>

Actually no, it's a lot less complexity, because it's all baked into
the language. You don't have to have the affix registry to figure out
how to parse a script into AST. The definition of a "literal" is given
by the tokenizer, and for instance, "-1+2j" is not a literal. How is
this going to impact your registry? The distinction doesn't matter to
Decimal or Fraction, because you can perform operations on them at
compile time and retain the results, so "-1.23d" would syntactically
be unary negation on the literal Decimal("1.23"), and -4/5f would be
unary negation on the integer 4 and division between that and
Fraction(5). But does that work with your proposed registry? What is a
"literal token", and would it need to include these kinds of things?
What if some registered types need to include them and some don't?

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

Reply via email to