[Python-ideas] Infix functions

Haoyi Li haoyi.sg at gmail.com
Wed Feb 26 23:13:14 CET 2014


>   $(_ ...)       # local lambda with no args

*haoyi$ sudo pip install macropy*
*haoyi$ python*
*Python 2.7.5 (default, Aug 25 2013, 00:04:04)*
*[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin*
*Type "help", "copyright", "credits" or "license" for more information.*

*>>> import macropy.console*
*0=[]=====> MacroPy Enabled <=====[]=0*

*>>> from macropy.quick_lambda import macros, f, _*



*>>> from random import random>>> random()0.26042432926429704>>>
local_lambda = f[random() + random()] >>>
local_lambda()0.9829393394632971>>> local_lambda()1.4040653196619832*

=)


On Wed, Feb 26, 2014 at 1:52 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>wrote:

> Andrew Barnert wrote:
>
>> On Feb 25, 2014, at 15:02, Greg Ewing <greg.ewing at canterbury.ac.nz>
>> wrote:
>>
>>  Also, this kind of style would make it very easy to
>>> make subtle mistakes by getting the colons in the
>>> wrong places.
>>>
>>
>> I'm not sure about that. I think in most cases, anywhere you put the
>> colons
>>
> wrong will be a SyntaxError.
>
> No, what I mean is forgetting to put a colon in front
> of an expression that should have one, or vice versa.
> It's related to my next point:
>
>
>  It's not quite the same thing as a Lisp macro, because
>>> the onus is on the caller to remember which arguments
>>> need to be quoted.
>>>
>>
> --
> Greg
>
> _______________________________________________
> 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/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140226/acaaf4c5/attachment.html>


More information about the Python-ideas mailing list