Chaim Frenkel writes:
: LW> P.S. I think we *could* let @foo and %bar return an object ref in scalar
: LW> context, as long as the object returned overloads itself to behave as
: LW> arrays and hashes currently do in scalar context.
:
: Isn't this an internals issue?
Not completely. The scalar value would visably be a built-in object:
@bar = (0,1,2);
$foo = @bar; # now means \@bar, not (\@bar)->num
print ref $foo, $foo->num, $foo->str, ($foo->bool ? "true" : "false");
^D
ARRAY3(0,1,2)true
One implication of this approach is that we'd break the rule that says
references are always true. Not clear if that's a problem. It's basically
already broken with bool overloading, and defined still works.
Larry