What's the deal with __buck?

Don nospam at nospam.com
Thu Jan 29 13:59:31 PST 2009


Bill Baxter wrote:
> On Fri, Jan 30, 2009 at 5:58 AM, Don <nospam at nospam.com> wrote:
>> Jarrett Billingsley wrote:
>>> On Thu, Jan 29, 2009 at 12:48 PM, Andrei Alexandrescu
>>> <SeeWebsiteForEmail at erdani.org> wrote:
>>>> BCS wrote:
>>>>> Hello Bill,
>>>>>> I guess what's required is the ability to define the __dollar in the
>>>>>> scope of a class/struct/template.
>>>>> I think that is the correct solution.
>>>> Ok, thanks to all. So __dollar is looked up at module scope for anything
>>>> that's not a built-in array.
>>>>
>>>> I thought some more about it and I think there's no need for __dollar.
>>>> It's enough that:
>>>>
>>>> a) In slice expressions and index expressions with one argument, $
>>>> expands
>>>> to value.length, where value is the object being indexed/sliced (if an
>>>> unnamed temporary, the value is of course only evaluated once)
>>>>
>>>> b) In index expressions with multiple arguments, $ expand to
>>>> value.length(i), where i is the zero-based argument position.
>>>>
>>>> This is exactly enough what's needed to make it all work. Infinite
>>>> ranges may define a symbolic infinite length and overload slicing on it.
>>> Sounds good.  Question - since length will work for multiple indices,
>>> will it ever be possible to have .. multiple slices?
>>>
>>> a[x1 .. x2, y1 .. y2] = b;
>> You can do that with opIndex already.
> 
> Can you?  How?  As far as I know any index expression with more than
> one  ..  in it automatically generates a compiler error.

Aargh, you're right. I remembered that I'd got it to generate an AST for 
me, but I forgot that I had put in a hack for ..



More information about the Digitalmars-d mailing list