Re: single named param
在 Sep 12, 2006 6:59 PM 時,Gaal Yahas 寫到: What invocant is constructed in this signature then? method foo ($just_a_named_param) Is the signature for &foo really the same as that of bar? sub bar ($just_a_named_param) As Larry said, they shouldn't be the same; the first one is &foo.signature === :($ : $just_a_named_param); The second one is: &bar.signature === :($just_a_named_param); I was sort of assuming you could tell by a signature if it was for a method or a sub. That's correct; the "method" keyword augments the signature with an unnamed "$" invocant if it's not explicitly specified. (In Pugs.Val.Code terms, that's nullID for both the p_label slot and (v_name . p_variable).) Cheers, Audrey
sub ($self: $foo ) (was: Re: single named param)
Larry Wall wrote: > > I'm trying to decide if > >sub ($self: $just_a_named_param) > > can meaningfully put anything into $self. It seems doubtful, and it should > probably be > >submethod ($self: $just_a_named_param) I agree. If sub ($self: $foo) works than it reduces privacy, since someone could call a sub like externally, when it wasn't intended. Mark
Re: single named param
On Tue, Sep 12, 2006 at 01:59:23PM +0300, Gaal Yahas wrote: : On Tue, Sep 12, 2006 at 06:46:50PM +0800, Audrey Tang wrote: : > >Does this mean a single named parameter called $x, or a default invocant : > >and a single required positional named $x? : > : > "A default invocant" prolly doesn't make sense there... There's : > nothing to "default" to. :-) : : What invocant is constructed in this signature then? : : method foo ($just_a_named_param) : : Is the signature for &foo really the same as that of bar? : :sub bar ($just_a_named_param) Maybe methods and submethods turn method foo ($just_a_named_param) into method foo ($ : $just_a_named_param) Since we regularized invocants, there's much less need for an empty invocant, so maybe the $ is required there if you put the :. If so, we should probably explicitly say that there are no variables of the form "$:", "$;", or "$,", so those will always be taken as "$ :", "$ ;", and "$ ," respectively. At least within signatures. In any case, prefix ':' is not an operator. In :(:$foo) the :$ starts a token, so you'd have to put space between to mean :(: $foo). : I was sort of assuming you could tell by a signature if it was for a : method or a sub. I'm trying to decide if sub ($self: $just_a_named_param) can meaningfully put anything into $self. It seems doubtful, and it should probably be submethod ($self: $just_a_named_param) So for the jet-lagged moment I think your assumption is valid. I might jet-delag at any moment, however... Larry
Re: single named param
2006/9/12, Gaal Yahas <[EMAIL PROTECTED]>: Does this mean a single named parameter called $x, or a default invocant and a single required positional named $x? "A default invocant" prolly doesn't make sense there... There's nothing to "default" to. :-) Audrey
Re: single named param
On Tue, Sep 12, 2006 at 06:46:50PM +0800, Audrey Tang wrote: > >Does this mean a single named parameter called $x, or a default invocant > >and a single required positional named $x? > > "A default invocant" prolly doesn't make sense there... There's > nothing to "default" to. :-) What invocant is constructed in this signature then? method foo ($just_a_named_param) Is the signature for &foo really the same as that of bar? sub bar ($just_a_named_param) I was sort of assuming you could tell by a signature if it was for a method or a sub. -- Gaal Yahas <[EMAIL PROTECTED]> http://gaal.livejournal.com/
single named param
I was writing tests for signatures and came across this ambiguity: :(:$x) Does this mean a single named parameter called $x, or a default invocant and a single required positional named $x? -- Gaal Yahas <[EMAIL PROTECTED]> http://gaal.livejournal.com/