[Python-ideas] Light-weight call-by-name syntax in Python
Nathaniel Smith
njs at pobox.com
Fri Feb 17 05:28:36 EST 2017
On Fri, Feb 17, 2017 at 2:22 AM, Stephan Houben <stephanh42 at gmail.com> wrote:
> Proposal: Light-weight call-by-name syntax in Python
>
> The following syntax
> a : b
> is to be interpreted as:
> a(lambda: b)
>
> Effectively, this gives a "light-weight macro system" to Python,
> since it allows with little syntax to indicate that the argument to
> a function is not to be immediately invoked.
>
> It is a generalization of special-case syntax proposals like
> delayed: <expr>
> In this proposal, `delayed' can be a normal callable.
Note that this is definitely a different proposal from the original,
since the original proposer's goal was to be able to use this with
existing, unmodified functions that expect a regular value, not a
lambda.
I don't really see how that goal can be accomplished without massively
revising Python's runtime model, so this doesn't really bother me, but
it should be noted :-).
Anyway, you might also be interested in:
https://mail.python.org/pipermail/python-ideas/2016-November/043590.html
which is a similar idea and some more motivating examples, except that
it allows for the full richness of Python's call syntax, and passes
ASTs rather than lambdas to allow for non-standard evaluation rules.
-n
--
Nathaniel J. Smith -- https://vorpus.org
More information about the Python-ideas
mailing list