What's the deal with __buck?
Jarrett Billingsley
jarrett.billingsley at gmail.com
Thu Jan 29 16:09:35 PST 2009
On Thu, Jan 29, 2009 at 6:00 PM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
>>
>> a[x1 .. x2, y1 .. y2] = b;
>
> That's rather exotic. After that the road is opened for free-form
> combinations of a .. b and a. But I can definitely see some good uses for
> it.
Hm.. if you _wanted_ to interleave slices and single indices, how
would you do it? How about we take a page from Python's book: it
doesn't (used to but no longer) distinguish between slicing and
indexing. It uses the same "operator overload" for both, but slicing
passes a 2-tuple as the "index", kind of like:
blah opIndex(int x) // used for a[0]
blarg opIndex(Slice!(int, int) x) // used for a[0 .. 1]
Assuming we have a "struct Slice(Lo, Hi) { Lo lo; Hi hi; }" type.
Then, you could just have opIndex[Assign] take multiple parameters -
like it does now. And of course, it could just take a tuple and
figure out what to do based on whether each thing is an int or if it's
a slice. Complex, but completely doable, and it still leaves simple
cases simple.
More information about the Digitalmars-d
mailing list