Crazy what-if idea for function/method calling syntax

Cameron Simpson cs at zip.com.au
Sun Jul 17 22:04:24 EDT 2011


On 17Jul2011 15:54, ΤΖΩΤΖΙΟΥ <tzotzioy at gmail.com> wrote:
| What if a construct
| 
|    xx(*args1, **kwargs1)yy(*args2, **kwargs2)
| 
| was interpreted as
| 
|   xxyy(*(args1+args2), **(kwargs1+kwargs2))
| 
| (Note: with **(kwargs1+kwargs2) I mean “put keyword arguments in the
| order given”, since dicts can't be added)
| 
| This construct is currently a syntax error. The intent of this idea is
| to help improve legibility.
| 
| Example:
|   def place_at(item, x, y): blah blah
| could be called as
|   place(item)_at(x, y)
[...]
| There is also a big window for misuse (i.e. break the function/method
| name in illogical places), but I would classify this under “consenting
| adults”. It might be suggested as good form that function names break
| at underscores, like my examples.

Another problem is the scope for error. I can easily imagine typing:

  x=foo(x)bah(y)

when I intended to type:

  x=foo(x)+bah(y)

Adding your syntax causes silent breakage later instead of immediate
syntax error now.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

hybrid rather than pure; compromising rather than clean;
distorted rather than straightforward; ambiguous rather than
articulated; both-and rather than either-or; the difficult
unity of inclusion rather than the easy unity of exclusion.
        - Paul Barton-Davis <pauld at cs.washington.edu>



More information about the Python-list mailing list