Distinguishing between scalars and objects (Re: RFC 21 (v1) Replace C<wantarray> with a generic C<wa)
[email protected] (Nathan Wiger) Fri, 04 Aug 2000 14:11:30 -0700
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Organization | Sun Microsystems |
| Message-ID | <[email protected]> |
First off, nice job Damian. This is the type of want() I've always want()ed (excuse the pun). :-) The one thing that isn't directly addressed (or maybe it is and I missed it) is how to figure out whether something wants an *generic* object or not. For example, right now I'm writing the localtime() RFC, and I think it would be really cool if want() could somehow distinguish between these: $date = localtime(); # scalar date $obj = localtime(); # localtime obj That way, you would be able to get the scalar $date, as well as an $obj that would let you get $obj->year directly. This mentions that somewhat: > =item I<Classname> > > The subroutine was called in a context that would like to see an object of the named > class returned: > > my Dog $spot = func(); # want 'Dog' returns true but doesn't seem to mention the generic case; i.e., when you just want "a class, any class" (i.e, as the return from a new()). I was thinking (this is pre-alpha brainstorming) that one might be able to overload ref() as the generic case in an LVALUE: my ref $obj = localtime(); Any ideas? Or did I miss something in the RFC? Thanks, Nate