[Compiler-sig] funcdef parameters
Finn Bock
bckfnn@worldonline.dk
Sun, 14 Apr 2002 13:47:32 GMT
Hi,
I'm trying to understand the 'arguments' production.
arguments = (identifier* args, identifier? vararg,
identifier? kwarg, expr* defaults)
First, I'll ignore the posibility of tuple parameter.
I'm guessing that 'vararg' is what is called 'starargs' in the Call
ctor. I'm also guessing that 'defaults' contain the keyword values like
this:
def foo(a, b, c=1, d=2, *lst, *kw): pass
->
arguments([a, b, c, d], lst, kw, [1, 2])
or maybe?
arguments([a, b, c, d], lst, kw, [None, None, 1, 2])
Second, we have to add tuple parameters and the simplest way I can see
looks like this.
@@ -85,8 +85,11 @@
except = (expr? type, assign? name, stmt* body)
-- XXX need to handle 'def f((a, b)):'
- arguments = (identifier* args, identifier? vararg,
+ arguments = (fpdef* args, identifier? vararg,
identifier? kwarg, expr* defaults)
+
+ fpdef = FpList(fpdef* list)
+ | FpName(identifier id)
-- keyword arguments supplied to call
keyword = (identifier arg, expr value)
regards,
finn