HaloO,
Larry Wall wrote:
...I think that should work. The *-1 value just means "one before
Whatever", and the dwim is, as you say, lazy. Or perhaps this generalizes
to an odd form of currying:
&replicate := * xx 42;
Ohh, let me get that in my own words: the rhs replicates a Whatever
into a list of 42 Whatever values, then a code variable is bound to
this list. How would one access that thing? Does replicate()[*-1]
return the last Whatever and replicate()[0] the first? How does one
make use of such a Whatever value?
But then it's not clear how the eventual victim would know how to
distinguish *+42 from *-42 if it's only getting some kind of closure
to call.
I don't get that. Do you mean replicate()[*+42] that would be one
after the last Whatever and replicate()[*-42] that would be the first
Whatever in the list but indexed from the back? Or do you want to
index into the Whatevers like it would be the case for a range 0..*
which dispatches to &infix:<..>:(Int,Whatever) and returns a range
that is lazy at the end. IOW, I don't understand what
&infix:<xx>:(Whatever,Int) returns. I mean what type of Whatever
value is it? I understand that it is 42 times the same thing in
a list but what it is is unspecified for the moment. Such a Whatever
value is sort of parametric and adapts to the environment it is
finally used in. The two uses I see right now is in ranges and as
array index.
BTW, are Whatever ranges applicable to arrays?
my @a = 0,1,2,3,4,5,6,7,8,9;
my $i = 5..*;
say @a[$i]; # prints 5 6 7 8 9
Is the Whateverness of the range kept and finally resolved
when applied to the array? Or does &postcircumfix:<[ ]> see
only a lazy range?
So I think we still have to dispatch to Whatever and let
the Whatever code extract any relevant relative information knowing
that a "dwim" was explicitly called for by use of *.
Could you make an example of what you mean here, please. Do you mean
a dispatch to &postcircumfix:<[ ]>?
Regards, TSa.
--