Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76817
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <travisgriggs@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'syntax': 0.04; 'pop': 0.05; '(so': 0.07; '21,': 0.07; 'expressions': 0.07; '"("': 0.09; 'boundaries': 0.09; 'chime': 0.09; 'counting': 0.09; 'creator': 0.09; 'executed': 0.09; 'expat': 0.09; 'imply': 0.09; 'literal': 0.09; 'statements': 0.09; 'subset': 0.09; 'python': 0.11; '":"': 0.16; '(something': 0.16; 'already,': 0.16; 'block.': 0.16; 'closures': 0.16; 'deferred': 0.16; 'denote': 0.16; 'distinct': 0.16; 'expression.': 0.16; 'happily': 0.16; 'indent': 0.16; 'keyword,': 0.16; 'modules,': 0.16; 'modules.': 0.16; 'parentheses': 0.16; 'personally,': 0.16; 'pythonic': 0.16; 'sought': 0.16; 'subject:?)': 0.16; 'terse': 0.16; 'threw': 0.16; 'top:': 0.16; 'weighed': 0.16; 'language': 0.16; 'wrote:': 0.18; '(not': 0.18; 'library': 0.18; 'looked': 0.18; 'all,': 0.19; 'stack': 0.19; '(in': 0.22; 'aug': 0.22; 'creating': 0.23; 'non': 0.24; 'compare': 0.26; 'recognized': 0.26; 'skip:" 20': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'character': 0.29; 'quickly': 0.29; "doesn't": 0.30; 'characters': 0.30; 'statement': 0.30; 'code': 0.31; 'lines': 0.31; 'are.': 0.31; 'comparison': 0.31; 'grouping': 0.31; 'reduced': 0.31; 'lists': 0.32; 'probably': 0.32; 'critical': 0.32; '(i.e.': 0.33; 'maybe': 0.34; 'could': 0.34; 'subject: (': 0.35; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'library.': 0.36; 'mass': 0.36; 'next': 0.36; 'hi,': 0.36; 'example,': 0.37; 'two': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'extremely': 0.39; 'functional': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'how': 0.40; 'expression': 0.60; 'guy': 0.60; 'liked': 0.60; 'truly': 0.60; 'tell': 0.60; 'simple': 0.61; 'first': 0.61; 'back': 0.62; 'offer': 0.62; 'complete': 0.62; 'header:Message-Id:1': 0.63; 'email addr:gmail.com': 0.63; 'show': 0.63; 'pick': 0.64; 'more': 0.64; 'land': 0.65; 'charset:windows-1252': 0.65; 'close': 0.67; 'believe': 0.68; 'brain': 0.68; 'covers': 0.68; 'subject': 0.69; 'miss': 0.74; '2014,': 0.84; 'circles': 0.84; 'glance': 0.84; 'greek': 0.84; 'island': 0.84; 'it\x92s': 0.84; 'i\x92d': 0.84; 'much,': 0.84; 'perspective.': 0.84; 'regularity,': 0.84; 'regularly.': 0.84; 'shrinking': 0.84; 'yours': 0.88; 'can\x92t': 0.91; 'graduates': 0.91; 'instantly.': 0.91; 'differences': 0.93; 'wanting': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=pXnmgd1Z3IVR52+dhtG/FJlCxx0uDO5I6QF31/9s9Oo=; b=lK1ncOdEyuFkd+k40au5ZLlnr+KhpMrELYQW96PWL6R1XczvKYvgW1mOIr3vNG9wzZ DBGmPpzujLLd6gaLkZRt3Wp6nzjmezzN58ODQEjlKesfp3xEaC9zpqB/Tdiyl3fI+5eP ZEB/9bHziGMm2aEjIF2ORqALHR3Rmt/RfMVlUfw5XKSoXd3mknkCOI7/1EArfZT8+O8G mN0m54dFo6DOfeBG4D6o7LzFndcdRnglt609esQc98d155378C93RUQ2yZ1DkHtm5WFC rRedibAG6M+Ynm2rghRy2w3hjLPdCsnD7n2Ey+fpS5n/+e2gpEDhvvVFBNx+UpsEm/ND IImQ== |
| X-Received | by 10.68.57.144 with SMTP id i16mr9271444pbq.48.1408737955012; Fri, 22 Aug 2014 13:05:55 -0700 (PDT) |
| Content-Type | text/plain; charset=windows-1252 |
| Mime-Version | 1.0 (Mac OS X Mail 7.3 \(1878.6\)) |
| Subject | Re: proposed syntax for multiline anony-functions (hopefully?) |
| From | Travis Griggs <travisgriggs@gmail.com> |
| In-Reply-To | <1bd05b41-ad00-4ce8-8678-de51205ebc3b@googlegroups.com> |
| Date | Fri, 22 Aug 2014 13:05:53 -0700 |
| Content-Transfer-Encoding | quoted-printable |
| References | <1bd05b41-ad00-4ce8-8678-de51205ebc3b@googlegroups.com> |
| To | python-list@python.org |
| X-Mailer | Apple Mail (2.1878.6) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13305.1408737958.18130.python-list@python.org> (permalink) |
| Lines | 69 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1408737958 news.xs4all.nl 2903 [2001:888:2000:d::a6]:38774 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:76817 |
Show key headers only | View raw
On Aug 21, 2014, at 12:55 AM, icefapper@gmail.com wrote:
> Hi, just wanting to do a shot in the dark,but maybe this syntax is Pythonic (in a "we-are-all-grown-ups" fashion, ahem)enough to get its way into the language
> this is what yours truly thinks: don't we all know that ":" means the next token must be an indent (mostly)? and doesn't the "(" and its alikes, [ and } begin an space-insensitive lexing context? so all we need is having an "space-sensitivity-stack" and the corresponding "(" counting stack and this way we could match opening and closing "()" and pop the space-sensitivity-stack whenever the "(" counting stack gets a 0 at the top:
<snip>
Those more pythonista than me have weighed in on the particulars. I’ll offer some more general thoughts.
While I dwell in the land of pythonistas, I’m a an expat from the Island of Smalltalk. I live happily in Pythonville and will probably never return to the shrinking island, I do miss Smalltalk’s block closures. I don’t miss them *too* much, because things like comprehensions as well as the large library of functional like modules, covers many of the use cases. But I do miss their simple elegance.
I do not like the python lambda. For two reasons.
One: In a language that sought to be approachable by simple people (i.e. non computer science graduates who would use it in addition to their scientific/education background), I can’t believe they threw in a 6 character phonetic description of a greek character to imply “fragment of code expression to be executed in a removed context”. Show a subset of keyword.kwlist to a non-comp-sci guy and tell me if when they see the ‘lambda’ betwixt the others, they don’t stop and think “huh, one of these is not like the others”.
Two: The reason that this subject circles regularity, because they used a keyword, it can only be used as a literal creator for a single line expression. So we keep coming back to “how can we do multiple expressions with a lambda/closure”.
For the unaware, the Smaltalk syntax for a literal block closure was a pair of [ ]. First of all, I liked that the characters actually looked like a “block” with the corners. I liked that it did not use parentheses. Parentheses are pretty loaded already, and it helped the brain pick out the differences instantly. I don’t like the OP’s proposal because I don’t think (def()) is distinct from normal grouping () statements. And I liked how terse they are. Two characters and you had a block. They are *everywhere* in the library. Compare that with how often you find ‘lambda’ in the python standard modules. I used to joke about the irony, that no language did more with functional closures than the all-objects-all-the-time Smalltalk, and that CLOS had a more robust object model than Smalltalk.
To me, for a multiple-expression (multi line or not) literal closure syntax to succeed, it must a) denote both the start and stop (not a leading keyword), b) be extremely terse so that the cost of creating closures is reduced c) not be confused with other common literal denotation so it can be quickly recognized when reading close (so [ and { are out for example, because of lists and dictionaries, and using < > would cause complete confusion because it’s hard at a glance to differentiate from a comparison operand).
Personally, I don’t think the desire to use lines as statement boundaries (something I like a lot) and at the same time to tersely pack multiple statements into a deferred code fragment, are reconcilable. And I don’t think there’s critical mass desire for them. So this subject will continue to resurface regularly. But I thought I’d chime in with a “foreigners” perspective.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 00:55 -0700
Re: proposed syntax for multiline anony-functions (hopefully?) Chris Angelico <rosuav@gmail.com> - 2014-08-21 18:18 +1000
Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 01:59 -0700
Re: proposed syntax for multiline anony-functions (hopefully?) Chris Angelico <rosuav@gmail.com> - 2014-08-21 19:05 +1000
Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 02:06 -0700
Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 02:27 -0700
Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 02:14 -0700
Re: proposed syntax for multiline anony-functions (hopefully?) Marko Rauhamaa <marko@pacujo.net> - 2014-08-21 12:27 +0300
Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 02:30 -0700
Re: proposed syntax for multiline anony-functions (hopefully?) alex23 <wuwei23@gmail.com> - 2014-08-22 15:15 +1000
Re: proposed syntax for multiline anony-functions (hopefully?) Terry Reedy <tjreedy@udel.edu> - 2014-08-21 06:07 -0400
Re: proposed syntax for multiline anony-functions (hopefully?) Travis Griggs <travisgriggs@gmail.com> - 2014-08-22 13:05 -0700
Re: proposed syntax for multiline anony-functions (hopefully?) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-23 19:20 +1000
Re: proposed syntax for multiline anony-functions (hopefully?) Dan Stromberg <drsalists@gmail.com> - 2014-08-22 16:48 -0700
Re: proposed syntax for multiline anony-functions (hopefully?) Dan Stromberg <drsalists@gmail.com> - 2014-08-22 16:58 -0700
Re: proposed syntax for multiline anony-functions (hopefully?) Marko Rauhamaa <marko@pacujo.net> - 2014-08-23 10:37 +0300
csiph-web