Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; 'python.': 0.04; 'args': 0.05; 'something,': 0.07; 'subject:based': 0.07; 'python': 0.08; 'args,': 0.09; 'content-type:multipart/signed': 0.09; 'figuring': 0.09; 'filename:fname piece:signature': 0.09; 'imo.': 0.09; 'integral': 0.09; 'omit': 0.09; 'suggestion.': 0.09; 'def': 0.13; '"python': 0.15; 'argument': 0.15; 'around,': 0.16; 'content-type:application/pgp-signature': 0.16; 'filename:fname piece:asc': 0.16; 'filename:fname:signature.asc': 0.16; 'functions.)': 0.16; 'head,': 0.16; 'kwargs': 0.16; 'more:': 0.16; 'objection': 0.16; 'subject: \n ': 0.16; 'subject:syntax': 0.16; 'syntactic': 0.16; 'unary': 0.16; 'unpacking': 0.16; 'vararg': 0.16; 'syntax': 0.16; 'examples': 0.16; 'wrote:': 0.18; 'arguments': 0.18; 'issue,': 0.18; 'report.': 0.18; 'stick': 0.18; '(which': 0.19; 'seems': 0.20; 'suggest': 0.20; 'trying': 0.21; 'header:In-Reply-To:1': 0.22; 'wonder': 0.23; 'picking': 0.23; '"this': 0.24; 'specify': 0.24; 'code': 0.25; '(in': 0.26; 'fact': 0.27; 'fix': 0.27; 'do.': 0.28; 'continuing': 0.28; "wasn't": 0.28; 'lists': 0.28; 'pass': 0.29; 'looks': 0.29; 'tail': 0.30; 'tuples': 0.30; 'equivalent': 0.31; 'certainly': 0.32; 'matching': 0.32; 'proposed': 0.32; 'idea': 0.32; 'pretty': 0.32; "isn't": 0.33; 'header:User-Agent:1': 0.33; 'instead': 0.33; 'there': 0.33; 'match': 0.34; 'to:addr:python-list': 0.34; 'it.': 0.34; 'checking': 0.34; 'too': 0.34; 'things': 0.34; 'identical': 0.34; 'latter': 0.34; 'puts': 0.34; 'searches': 0.34; '(not': 0.35; 'issue': 0.35; 'google': 0.35; 'subject:/': 0.35; 'starting': 0.36; 'bigger': 0.37; 'sequence': 0.37; 'but': 0.37; 'except': 0.37; 'received:192': 0.37; 'another': 0.37; 'think': 0.37; 'received:128': 0.37; 'could': 0.37; 'some': 0.38; 'received:192.168.0': 0.38; 'difficult': 0.39; 'should': 0.39; 'called': 0.40; "it's": 0.40; 'hit': 0.40; 'missing': 0.40; 'python.org': 0.40; 'to:addr:python.org': 0.40; 'might': 0.40; 'received:192.168': 0.40; 'more': 0.61; 'type': 0.61; 'types': 0.61; 'course,': 0.62; 'strange': 0.68; 'dealing': 0.69; 'relevant': 0.70; 'size.': 0.71; 'encountered': 0.73; 'forth': 0.77; 'grand': 0.77; 'buck': 0.84; 'common,': 0.84; 'distinguish': 0.84; 'newbie,': 0.84; 'packing': 0.84; 'sense"': 0.84; 'choose.': 0.93; 'subject:\t': 0.93 Date: Sat, 17 Dec 2011 23:33:27 -0600 From: Evan Driscoll User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Pythonification of the asterisk-based collection packing/unpacking syntax References: <841f4d29-f50b-4b0b-912b-b497fb6e60ec@t16g2000vba.googlegroups.com> <15424060.724.1324183952802.JavaMail.geo-discussion-forums@prix23> In-Reply-To: <15424060.724.1324183952802.JavaMail.geo-discussion-forums@prix23> X-Enigmail-Version: 1.3.4 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig6AB08404BE5104951859E63F" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 99 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324186443 news.xs4all.nl 6916 [2001:888:2000:d::a6]:33085 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17437 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6AB08404BE5104951859E63F Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 12/17/2011 22:52, buck wrote: > Try these on for size. > > head, @tuple tail =3D sequence=20 > def foo(@list args, @dict kwargs): pass=20 > foo(@args, @kwargs) > > For backward compatibility, we could say that the unary * is identical = to @list and unary ** is identical to @dict. > I like this idea much more than the original one. In addition to the arguments buck puts forth, which I find compelling, I have one more: you go to great length to say "this isn't really type checking in any sense" (which is true)... but then you go forth and pick a syntax that looks almost exactly like how you name types in many languages! (In fact, except for the fact that it's inline, the 'object :: type' syntax is *exactly* how you name types in Haskell.) buck's syntax still has some of the feel of "I wonder if this is type checking" to a newbie, but much much less IMO. I have a bigger objection with the general idea, however.It seems very strange that you should have to specify types to use it. If the */** syntax were removed, that would make the proposed syntax very very unusual for Python. I could be missing something, but I can think of any other place where you have to name a type except where the type is an integral part of what you're trying to do. (I would not say that choosing between tuples and lists are an integral part of dealing with vararg functions.) If */** were to stick around, I could see 99% of users continuing to use them. And then what has the new syntax achieved? You can fix this if you don't require the types and just allow the user to say "def foo(@args)" and "foo(@args)". Except... that's starting to look pretty familiar... (Not to mention if you just omit the type from the examples above you need another way to distinguish between args and kwargs.) I have one more suggestion. I do have one more thing to point out, which is that currently the Python vararg syntax is very difficult to Google for. In the first pages of the four searches matching "python (function)? (star | asterisk)", there was just one relevant hit on python.org which wasn't a bug report. I certainly remember having a small amount of difficulty figuring out what the heck * and ** did the first time I encountered them. This would suggest perhaps some keywords might be called for instead of operators. In the grand scheme of things the argument packing and unpacking are not *all* that common, so I don't think the syntactic burden would be immense. The bigger issue, of course, would be picking good words. This also helps with the issue above. Let's say we'll use 'varargs' and 'kwargs', though the latter too well-ingrained in code to steal. (I don't want to get too much into the debate over *what* word to choose. Also these don't match the 'head, *tail =3D l' syntax very well.) Then we= could say: def foo(varargs l, kwargs d): bar(varargs l, kwargs d) and varargs would be equivalent to * and kwargs would be equivalent to **. But then you could also say def foo(varargs(list) l, kwargs(dict) d) Evan --------------enig6AB08404BE5104951859E63F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJO7XsnAAoJEAOzoR8eZTzgYsAH/2Q/po+5w9/FA7vOgx1cii6X WBHx772m/C24XKt8U2SM4a3rT3QUs69L9LE3Sk8uzq6OuQHycqjxdvhwFUJWqX+m 5jQw15VK554/bSI8b+AX3oLsam8xbSsZ9J2Ru49KoWMcj7R0ns1vJES4MFwu9L+M y9E0/miUcSpGQe18N1VlYmEdF5wJcg4vitJrimLC5CLttWZiUq94CoaQY2ju3cZk bg14ISsOlmy3uW8D84WUd7YxI4dPVyTg2PAhnwdZgpTnCvSe12Mu6R8WUxBvbzwj xvle/VOXhgC8msocMBA756A2KvJEtLwCofBrjeEnVHKn0S7QyUMjpXDsZoBUS7E= =2y+K -----END PGP SIGNATURE----- --------------enig6AB08404BE5104951859E63F--