3 ms·
A similar feature was already proposed and rejected: http://www.python.org/dev/peps/pep-0340/ http://www.python.org/dev/peps/pep-0340/ Anyway, I'm kind of sad
by sah 18y ago
A similar feature was already proposed and rejected: http://www.python.org/dev/peps/pep-0340/ http://www.python.org/dev/peps/pep-0340/
Anyway, I'm kind of sad that people seem to want a straight copy of Ruby's blocks. I'd prefer syntax that allowed passing more than one block to a function, like the C-like syntax I proposed here:
http://www.hackerdashery.com/2006/10/code-blocks-and-c-like-lambda.html http://www.hackerdashery.com/2006/10/code-blocks-and-c-like-...
- tav 18y ago@sah Nice! Sadly it wouldn't ever fly in the Python context, but I like it nevertheless!
- russell 18y agoActually 340 was withdrawn in favor of the 'with' statement, so blocks haven't been ruled out, as far as I can see. However, it will have to be Pythonic (no braces of block terminators) and well thought out.
- Jebdm 18y agoI was wondering if the one-block limit bothered anyone else. Maybe something like Haskell's where clause: map(foo, pairs) where: pairs = [(0,1), (20, 10), (30, 10)] def foo(pair): a = pair[1] * 2 b = pair[0] * a return (b, a) I'm not terribly familiar with Python's grammar, so it might be difficult to introduce a closing where-clause without ambiguity. In that case, it might be useful to use a do clause as well: do: <statements> where: <statements> Another alternative would be to simply create a real function literal syntax (i.e., lambda that doesn't suck).
- jamongkad 18y agoThe only time I see where Python will adopt a lambda that doesn't suck, is the day when the community itself embraces functional programming. At the rate that is going and from what I've read from the commenters of the article. I don't think that's happening anytime soon.
- cturner 18y agoI think that's right. Since the early days there have been lots of people willing to say (from an academic bent) how python is basically just scheme, and (from a practical bent) how the likes of python+libraries is good enough to make scheme unnecessary. Programming in scheme feels very different to scheme, largely because of the neutered lambda.