Re: RFC 98 (v1) context-based method overloading

[email protected] (Hildo Biersma) Mon, 14 Aug 2000 20:10:26 +0100
Newsgroups perl.perl6.language.subs
Organization Morgan Stanley Dean Witter & Co.
Message-ID <[email protected]>
> The other way C++ allows you to overload a named function is
> by return type.  This document is a companion piece to
> a similarly named one about protoypes.  It replaces old Perl's
> "wantscalar" and "wantarray" kluges, which can now be deprecated,
> with a cleaner interface allowing decisions which are possible to
> make at compile time to be made then.

C++ emphatically does *not* support overloading on return type only. 
That has a very simple reason: unlike Pascal, C++ does not force you to
assign the result of a method or function call to a variable, so it
cannot always tell what you're doing.

The same reason pretty much goes for perl: if I have array and hash
versions of a function, how can it tell which one to call if I don't
assign the results?

Hildo