Re: RFC 98 (v1) context-based method overloading
[email protected] (Chaim Frenkel) 14 Aug 2000 18:10:52 -0400
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Message-ID | <[email protected]> |
And what will aSub decide is it's context? @foo = (1, 2, 3, aSub) If I have to write scalar(aSub) then I see no point in this RFC. And why shouldn't the caller decide? What is the gain in having perl do the dirty work. <chaim> >>>>> "ABH" == Ask Bjoern Hansen <[email protected]> writes: >> =head1 ABSTRACT >> >> 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. >> >> =head1 DESCRIPTION >> >> Defining multiple subroutines with both the same name and the same calling >> interface that explicitly return items of differing types is now >> allowed. subject to the following: >> >> =over >> >> =item compile-time >> >> the return-type expectation of all method calls meaning to take advantage >> of this feature must be clear from explicit type tags available at compile time. >> >> =item what constitutes a context? >> >> We are familiar with "scalar context" and "array context" from perl5 and >> previous. Perl6 gives us user-defined contexts as well as user defined >> types or all sorts. Any unique string can be a context, for the purposes >> of context-based method overloading, and Perl will attempt to guess a >> reasonable base class for the given "context." Use of undeclared context >> specifiers will of course generate warnings. -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183