[prev in list] [next in list] [prev in thread] [next in thread]
List: python-ideas
Subject: Re: [Python-ideas] Infix functions
From: Haoyi Li <haoyi.sg () gmail ! com>
Date: 2014-02-26 22:13:14
Message-ID: CALruUQKCCfUG4mD5FQod071MKYu3=fsuDqBoRQgYR+FgS31WoA () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
> $(_ ...) # 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@canterbury.ac.nz>wrote:
> Andrew Barnert wrote:
>
>> On Feb 25, 2014, at 15:02, Greg Ewing <greg.ewing@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@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
[Attachment #5 (text/html)]
<div dir="ltr">> <span style="font-family:arial,sans-serif;font-size:13px"> $(_ \
...) # local lambda with no args</span><div><span \
style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><div><b>haoyi$ \
sudo pip install macropy</b></div>
<div><b>haoyi$ python</b><br></div><div><b>Python 2.7.5 (default, Aug 25 2013, \
00:04:04)</b></div><div><b>[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on \
darwin</b></div><div><b>Type "help", "copyright", \
"credits" or "license" for more information.</b></div>
<div><b><br></b></div><div><b>>>> import \
macropy.console</b></div><div><b>0=[]=====> MacroPy Enabled \
<=====[]=0</b></div><div><b><br></b></div><div><b>>>> from \
macropy.quick_lambda import macros, f, _</b></div>
<div><b><br></b></div><div><b><div>>>> from random import \
random</div><div>>>> \
random()</div><div>0.26042432926429704</div><div><br></div><div>>>> \
local_lambda = f[random() + random()]</div><div>
>>> local_lambda()</div><div>0.9829393394632971</div><div><br></div><div>>>> \
local_lambda()</div><div>1.4040653196619832</div></b></div></div><div><b><br></b></div><div>=)</div></div><div \
class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Feb 26, 2014 at 1:52 PM, Greg Ewing <span \
dir="ltr"><<a href="mailto:greg.ewing@canterbury.ac.nz" \
target="_blank">greg.ewing@canterbury.ac.nz</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">
Andrew Barnert wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div class=""> On Feb 25, 2014, at 15:02, Greg Ewing <<a \
href="mailto:greg.ewing@canterbury.ac.nz" \
target="_blank">greg.ewing@canterbury.ac.nz</a>> wrote:<br> <br>
</div><div class=""><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> Also, this kind of style would \
make it very easy to<br> make subtle mistakes by getting the colons in the<br>
wrong places.<br>
</blockquote>
<br>
I'm not sure about that. I think in most cases, anywhere you put the colons<br>
</div></blockquote><div class="">
wrong will be a SyntaxError.<br>
<br></div>
No, what I mean is forgetting to put a colon in front<br>
of an expression that should have one, or vice versa.<br>
It's related to my next point:<div class="im HOEnZb"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> It's not quite the same thing \
as a Lisp macro, because<br> the onus is on the caller to remember which \
arguments<br> need to be quoted.<br>
</blockquote></blockquote>
<br></div><span class="HOEnZb"><font color="#888888">
-- <br>
Greg</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" \
target="_blank">Python-ideas@python.org</a><br> <a \
href="https://mail.python.org/mailman/listinfo/python-ideas" \
target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-ideas</a><br> \
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" \
target="_blank">http://python.org/psf/<u></u>codeofconduct/</a><br> \
</div></div></blockquote></div><br></div>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic