Steve Fink wrote:
> I don't know whether Perl6 or any other language we want to be nice to
> has *non-constant* defaults.
Ruby appears to support non-constant, mutable defaults:
% irb
irb(main):001:0> $foo=[]
[]
irb(main):002:0> def x(n=$foo)
irb(main):003:1> n << 1
irb(main):004:1> end
nil
irb(main):005:0> x
[1]
irb(main):006:0> x
[1, 1]
irb(main):007:0> x
[1, 1, 1]
irb(main):008:0> x([1, 2, 3])
[1, 2, 3, 1]
irb(main):009:0> $foo
[1, 1, 1]
irb(main):010:0> $foo=[]
[]
irb(main):011:0> x
[1]
I'm not saying anyone in their right mind _uses_ this feature,
but there it is.
--
Steven
"There should be a psychology of feet. For do we not
make decisions with our legs, and walk about on our brains?
What do you mean, `No, not really,'?"
-from "The Notebooks of Mauve'Bib--Outtakes, Bloopers,
and Unconvincing Maxims," Edited by the Princess Serutan.