Ok, so log and log10:
multi sub Math::Basic::log (: Num ?$x = $CALLER::_, Num +$base);
&log10<> := &log<>.assuming:base(10);
What does log get in this case:
for @x {
log10();
}
Does the curried log10 execute the defaulting for the sub it's based on
(and thus need run-time access to the default value, which I assume is
not in the signature) or does it leave defaulting up to log, in which
case, how does log find the right $_?
--
Aaron Sherman <a...@ajs.com>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback
>Ok, so log and log10:
>
> multi sub Math::Basic::log (: Num ?$x = $CALLER::_, Num +$base);
> &log10<> := &log<>.assuming:base(10);
>
>What does log get in this case:
>
> for @x {
> log10();
> }
>
>Does the curried log10 execute the defaulting for the sub it's based on
>(and thus need run-time access to the default value, which I assume is
>not in the signature) or does it leave defaulting up to log, in which
>case, how does log find the right $_?
>
I had assumed that wrapper a curries function generates does not alter
who the CALLER is. Therefore, when log10() is called, the CALLER for
log() is the same as the CALLER for log10.
IMO, if this is not the case, it severely limits the utility of curried
functions. Comments from @Larry requested.
-- Rod Adams
Makes sense to me. I don't think .assuming should assume anything that
is not explicitly specified as assumed, so defaults should not resolve
till the "real" call.
Larry
Yes on part 2, but on part 1... not sure. Anyone?
> 2) More important: isn't the multi without invocants useless
> or even outright wrong? Or shall it indicate an undispatched,
> compile-time, declaration-based, overloaded function ala C++?
> Does such a thing exist in Perl6?
I don't know the MMD system well enough to be sure (I became aware of
how multi subs work two days ago). Certainly S06 doesn't imply that this
is valid. I'll have to re-read the relevant bits of A12, unless a
certain former maintainer wants to speak up.... :)