Buddha Buck <[EMAIL PROTECTED]> wrote:
=
=At 11:26 AM 8/23/00 -0700, Larry Wall wrote:
=
=>I expect that we'll get more compile-time benefit from
=>
=> my HASH sub foo {
=> ...
=> }
=>
=> %bar = foo();
=
=So how would you fill in the type in:
=
=my TYPE sub foo {
= ...
= if (wanthash()) { return %bar; }
= if (wantarray()) { return @baz; )
= if (wantscalar()) { return $quux; };
=}
=
=$scalar = foo();
=@array = foo();
=%hash = foo();
=
=>Larry
I don't know if it fits in the scheme of things,
but Ada allows multiple subroutines of the same
name, and it would know which one to call based
on the type of the parameter passed in.
my SCALAR sub foo {}
my HASH sub foo {}
my ARRAY sub foo {} # and so,
my %hash = foo(); # would do the right call
not that I'm recommending Ada be the language
for Perl 6 to emulate. but the overload.pm
package allows you to override operators
based on the package the objects come from,
i.e. '+' has different meanings depending
on what package the thing being added was
blessed into.
so it wouldn't be a concept foreign to Perl.
Greg