Re: Closures and CALLER

2005-05-18 Thread TSa (Thomas Sandlaß)
Aaron Sherman wrote:
Ok, so log and log10:
 multi sub Math::Basic::log (: Num ?$x = $CALLER::_, Num +$base);
 log10 := log.assuming:base(10);
Sorry, I don't want to interfere but two nit-pickings from me:
1) It's log10:() and log:(: Num ?$, Num +$) these days, isn't it?
   And I'm unsure about the meaning of the first. And shouldn't you
   use the ::= operator?
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?
Regards,
--
TSa (Thomas Sandlaß)


Re: Closures and CALLER

2005-05-18 Thread Aaron Sherman
On Wed, 2005-05-18 at 14:57, TSa (Thomas Sandlaß) wrote:
 Aaron Sherman wrote:
  Ok, so log and log10:
  
   multi sub Math::Basic::log (: Num ?$x = $CALLER::_, Num +$base);
   log10 := log.assuming:base(10);
 
 Sorry, I don't want to interfere but two nit-pickings from me:
 
 1) It's log10:() and log:(: Num ?$, Num +$) these days, isn't it?
 And I'm unsure about the meaning of the first. And shouldn't you
 use the ::= operator?

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 :)

-- 
Aaron Sherman [EMAIL PROTECTED]
Senior Systems Engineer and Toolsmith
It's the sound of a satellite saying, 'get me down!' -Shriekback




Closures and CALLER

2005-05-17 Thread Aaron Sherman
Is it a bad sign that I'm still on the first section of S29, getting up
to speed? Sigh... I'll get there, really. This is another question from
my reading this morning.

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 [EMAIL PROTECTED]
Senior Systems Engineer and Toolsmith
It's the sound of a satellite saying, 'get me down!' -Shriekback




Re: Closures and CALLER

2005-05-17 Thread Rod Adams
Aaron Sherman wrote:
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


Re: Closures and CALLER

2005-05-17 Thread Larry Wall
On Tue, May 17, 2005 at 01:01:48PM -0500, Rod Adams wrote:
: Aaron Sherman wrote:
: 
: 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.

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