Justin Walker on Tue, 01 Feb 2005 21:41:11 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: optional argument behavior |
On Feb 1, 2005, at 12:18, Igor Schein wrote:
Hi, Since I'm not sure whether it's a bug or a feature, I'm posting it here instead of reporting a bug: ? f(a,b=a)=[a,b] ? f(1) [1, a] For a very long time I've operated under ( a possibly false ) assumption that the correct answer here would be [1, 1]
I'll take a leap of imagination and say that, in f(a,b=a)=....the first 'a' is a formal argument (variable name), while the second instance will be assumed to come from the environment (at this point in the parsing, the formal variable 'a' has no existence).
Since (presumably) you have nothing in your environment named 'a', the assignment "b=a" will assign the symbol "a" to the formal argument 'b' if no value is provided in a call.
Sounds like a feature. Cheers, Justin -- Justin C. Walker, Curmudgeon-At-Large * Institute for General Semantics | When LuteFisk is outlawed | Only outlaws will have | LuteFisk *--------------------------------------*-------------------------------*