[Python-ideas] User-defined literals
Nick Coghlan
ncoghlan at gmail.com
Fri Jun 5 00:31:57 CEST 2015
On 5 Jun 2015 00:25, "Paul Moore" <p.f.moore at gmail.com> wrote:
>
> On 4 June 2015 at 14:48, Nick Coghlan <ncoghlan at gmail.com> wrote:
> > On 4 June 2015 at 23:06, Paul Moore <p.f.moore at gmail.com> wrote:
> >> As a straw man how about a new syntax (this won't work as written,
> >> because it'll clash with the "<" operator, but the basic idea works):
> >>
> >> LITERAL_CALL = PRIMARY "<" <any source character except right
> >> angle bracket>* ">"
> >
> > The main idea I've had for compile time metaprogramming that I figured
> > I might be able to persuade Guido not to hate is:
> >
> > python_ast, names2cells, unbound_names =
> > !(this_is_an_arbitrary_python_expression)
>
> The fundamental difference between this proposal and mine is (I think)
> that you're assuming an arbitrary Python expression in there (which is
> parsed), whereas I'm proposing an *unparsed* string.
No, when you supplied a custom parser, the parser would have access to the
raw string (as well as the name -> cell mapping for the current scope).
The "quoted AST parser" would just be the default one.
Cheers,
Nick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150605/c0aae15e/attachment.html>
More information about the Python-ideas
mailing list