On 4 June 2018 at 11:59, Pål Grønås Drange <paal.dra...@gmail.com> wrote:
> One thing that could solve both this proposal and the aforementioned
> SI-proposition by Ken Kundert, could be supporting user-defined
> literals.  Suppose that __litXXX___ would make XXX a literal one could
> use as a suffix for numbers and strings (and lists, dicts, sets?).
>
> A user-defined literal could be defined as __lit<insert literal>__,
> though I don't know how to import it.

The killer would be putting together a full proposal, though. Unless
you mean something very different from the norm when you say
"literal", literals are evaluated very early in the parsing process,
long before user-defined functions are accessible.

If what you actually mean is a specialised function calling syntax
(where NNN_suf is parsed as the a "literal call" of "suf" with the
number NNN as an argument, so it translates to a call to (something
like) __lit_suf__(NNN) at runtime, then that's probably possible, but
it's extremely unclear why that function-call syntax has any
significant advantage over the standard syntax suf(NNN).

"readability" is notoriously difficult to argue, and "allows
construction of domain-specific languages" is pretty much an anti-goal
in Python. So what's left to justify this?

Paul
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to