Re: RFC 132 (v1) subroutines should be able to return an lvalue
[email protected] ((Johan Vromans)) 20 Aug 2000 22:17:12 +0200
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Message-ID | <[email protected]> |
Chaim Frenkel <[email protected]> writes: > JV> An attribute would > > JV> - require the sub to be consequent in what it returns; > > I can't parse that line. With an lvalue atttribute, a sub is assumed to always return an lvalue. The lreturn proposal makes it possible for a sub to determine at run time whether it's going to return an lvalue or something else. > > JV> - require the sub to be predeclared before it can be used; > > lvalueness seems to be appropropriate. The point is that the sub needs to be predeclared. > These two should have different actions. > > $foo = &foo; > &foo = $foo; > > Perl needs a value for one, and a reference for the other. I'm not sure I understand what you trying to say here. Please explain. > JV> - make it unfeasable for methods. > > Why? All methods for the same OO hierarchy should have the same signature. Assume class Foo has a method m that returns a scalar lvalue, and class Bar has a method m that returns an array lvalue. The following code is now perfectly legal (though weird): my $o = $some_condition ? Foo::->new() : Bar::->new(); $o->m = another_sub(); 'another_sub' calls wantarray. What should it return? -- Johan