On Tue, 28 May 2002, Glenn Linderman wrote:

> "with" reads very nicely, but we already have a perl6 precedent,
> perhaps... how about reusing "when" as the method name for currying? 
> This may not curry favor with Damian, but I suggest
> 
>   my & half = & div.when(y => 2);
> 
> would declare the subroutine "half" to be equal to the subroutine "div"
> when the parameter y is given the value 2.  The code and the English
> both read very nicely IMHO, and virtually identically, and the English
> version seems even more clear to me when using "when" rather than with
> "with". 
> 
> Further, there is a nice analogy with the usage of the keyword "when" in
> a given clause and the usage of the method name "when" to perform
> currying: both "when"s specify particular values that control the choice
> of code to be executed.  The "given" keyword supplies the 'parameters'
> for the "given" statement, and the original function declaration
> supplies the parameters for the original function.

It is precisely that similarity that's going to become confusing. A big 
problem with Perl 5, as I have seen, is that it takes a lot of effort to 
learn. Overloading C<when> will give learners a really hard time. "Wait, 
so when I give a variable after it then a block it does that block... but 
if I give a dot before it it returns a function?" they'd seem to say.

Wait, does this have any meaning?:

  my &half = \div(y => 2)

Is backslash even a valid operator for reference anymore? If so, this 
makes sense to me.

Luke

Reply via email to