--- Michael Lazzaro <[EMAIL PROTECTED]> wrote: > These lines all declare @a to be an array that stores ints. That > would imply that the "is Array" part is actually instantiating > (C<new>ing) the array... you're not saying that @a "can someday > hold an array obj", you're saying it already _is_ an array obj. > > So we're using "is Blah" here as a method of creating an > already-instantiated object, not just typing a variable(?) But > that, in turn, would imply that:
When you declare a variable, but don't assign to it, what value is stored in it? This answer could be: nothing -- its autovivified on its first use. If that first use is an assignment, then the variable's type determines what constructor to use. Thus: my (@a,@b,@c) is MyArray; ... @a = (1,2,3); # calls MyArray.new(List) @b = Array.new(1,2,3); # calls MyArray.new(Array) print int(@c); # calls MyArray.new() This could easily be extended to Scalars: we could autovivify on first use of an uninitialized variable. The default Scalar class's .new method would create an undef value; but other classes could do something more interesting. Dave. __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com