Crazy what-if idea for function/method calling syntax
steve+comp.lang.python at pearwood.info
Mon Jul 18 07:54:37 CEST 2011
On Mon, 18 Jul 2011 08:54 am ΤΖΩΤΖΙΟΥ wrote:
> Jumping in:
> 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.
I don't think it does that. I think it is misleading, as it looks like two
independent function calls. It also makes it hard to search for a function
call -- instead of searching for
you have to now search for
and so on.
> def place_at(item, x, y): blah blah
> could be called as
> place(item)_at(x, y)
You would probably like the Xtalk family of languages, starting with
Hypertalk from Apple in the late 80s or early 90s.
There's a neat implementation here: http://code.google.com/p/openxion/
Xtalk includes syntax like this:
put newStr into character 23 to 42 of theStr
put suffix after theStr
delete first char of theStr
although this only applied to built-in functions, not user-functions.
More information about the Python-list