May 21, 2009
Andrei Alexandrescu wrote:
> struct R
> {
>     bool empty();
>     ref int front();
>     void popFront();
> }
> 
> ref int popNext(ref R fwdRange)
> {
>     auto result = & fwdRange.front();
>     fwdRange.popFront;
>     return *result;
> }
> 
> void main()
> {
>     R r;
>     int x = r.popNext;
> }
> 
> This should work, I just noticed with surprise it doesn't. It's a bug, specifically bug 3015:
> 
> http://d.puremagic.com/issues/show_bug.cgi?id=3015

Yes. Oh yes. YES!!!
May 21, 2009
Nick Sabalausky wrote:
> "Andrei Alexandrescu" <SeeWebsiteForEmail@erdani.org> wrote in message news:gv2hj8$k1n$1@digitalmars.com...
>> dsimcha wrote:
>>
>> Consider:
>>
>> struct R
>> {
>>     bool empty();
>>     ref int front();
>>     void popFront();
>> }
>>
>> ref int popNext(ref R fwdRange)
>> {
>>     auto result = & fwdRange.front();
>>     fwdRange.popFront;
>>     return *result;
>> }
>>
>> void main()
>> {
>>     R r;
>>     int x = r.popNext;
>> }
>>
>> This should work, I just noticed with surprise it doesn't. It's a bug, specifically bug 3015:
>>
>> http://d.puremagic.com/issues/show_bug.cgi?id=3015
>>
> 
> I thought that was only supposed to work for arrays. Has that changed? If so, what's the new rule?

If a.fun(args) doesn't find fun, rewrite to fun(a, args).

Andrei
May 21, 2009
Andrei Alexandrescu wrote:
> dsimcha wrote:
>> Please, please, please PLEASE, PRETTY PLEASE FOR THE LOVE OF GOD
>> ALMIGHTY tell me
>> you're not serious!!!  Isn't changing the interface such that forward
>> ranges are
>> no longer effectively a subtype of input ranges a bit drastic?  Or do
>> you have
>> some magic up your sleeve that, given any forward range, will
>> automatically call
>> popFront, and then front, when popNext is called, using extension
>> function hacks
>> or something?
> 
> Consider:
> 
> struct R
> {
>     bool empty();
>     ref int front();
>     void popFront();
> }
> 
> ref int popNext(ref R fwdRange)
> {
>     auto result = & fwdRange.front();
>     fwdRange.popFront;
>     return *result;
> }
> 
> void main()
> {
>     R r;
>     int x = r.popNext;
> }
> 
> This should work, I just noticed with surprise it doesn't. It's a bug, specifically bug 3015:
> 
> http://d.puremagic.com/issues/show_bug.cgi?id=3015
> 
> Andrei

It was in the talk at the first conference as a 'todo for v2', but it's still on the todo list. :)

Later,
Brad
1 2
Next ›   Last »