On Tue, Jan 30, 2007 at 09:29:03PM +0100, TSa wrote:
: HaloO,
:
: [EMAIL PROTECTED] wrote:
: >+Alternately, C<*+0> is the first element, and the subscript dwims
: >+from the front or back depending on the sign. That would be more
: >+symmetrical, but makes the idea of C<*> in a subscript a little more
: >+distant from the notion of "all the keys", which would be a loss,
: >+and potentially makes C<+*> not mean the number of keys.
:
: The distinction of the three cases would be through dispatch
: to different functions. The plain * goes to
: &postcircumfix<[ ]>:(Array,Whatever) while the other two go
: to &infix:<+>(Whatever,Int) and &infix:<->:(Whatever,Int)
: respectively. In the latter cases the Whatever type somehow must
: package the array.
I don't think we want Whatever to package the array, since...
: Perhaps it is actually Whatever of Array or
: somesuch. The return value is a normal Int suitable for indexing
: the array. Perhaps we need to restrict the second parameter to
: UInt unless these two operators wrap around depending on sign ;)
: That is @array[*+(-1)] actually retrieves that last entry and
: @array[*-(-1)] the first =:()
:
: Can the index be set up before using it in an array index?
:
: my @a = 1,2,3;
: my $x = *-1;
: say @a[$x]; # prints 3
:
: Would &infix:<-> return a lazy Whatever value that becomes
: a specific index when it hits &postcircumfix<[ ]>? That is
: we have something like Whatever arithmetic?
...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;
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. 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 *.
Larry