Okay, I'm thinking the core will have four distinct perl variable types 
internally:

* Scalar
* Hash
* Array
* List

Scalars, hashes, and arrays are pretty much what you'd expect. Lists, 
though, are the interesting bit.

The big reason for them is efficiency--we're basically deferring 
flattening. It means, for example, that if someone does this:

   my @foo;
   @foo = bar();

   sub bar {
     my @arr;
     $arr[time]=14;
     return(@arr, 12);
   }

the return from the sub is actually two elements rather than a zillion, and 
the final assignment of the return boils down to an array rehoming with a 
push on the end. There are other useful cases, for example this:

   ($foo, $bar) = (@baz, @xyzzy);

wouldn't go flatten anything, just snag the first two elements of @baz, or 
whatever's needed from @xyzzy if @baz isn't big enough. If an element of 
the list isn't used then it's never evaluated.

Active data, for example function calls, would always be evaluated (though 
if it returns a list that list would be substituted in rather than 
flattened) since perl does guarantee that happens.

The part I'm waffling on (and should ultimately punt to Larry) is what to 
do with lazy data, and what exactly counts as lazy data anyway. For 
example, tied variables certainly aren't passive data, but should they be 
evaluated if they aren't used? If you do this:

   ($foo, $bar) = (@baz, "12", 15, $some_tied_scalar);

should the FETCH method of $some_tied_scalar be called unconditionally, 
even though we don't use it? (I'd argue yes, but prefer no... :)

Also one side-effect of this, if we allow it, is to have a list masqerade 
(under the hood, at least) as another variable type. We could, say, see this:

   @foo = (@bar, @baz);

but actually defer evaluating the list and doing the assignment until 
either @foo, @bar, or @baz is accessed. (Potentially holding off even 
further--things like scalar() on @foo, for example, wouldn't require 
finishing the assignment, and neither would something simple like $foo[12])

Anyway, that's what I'm thinking about at the moment. Comments? (Keeping in 
mind that we can't really decide things that are perl-visible without the 
OK of Larry)

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to