August 13, 2014
On Wed, Aug 13, 2014 at 06:31:32PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
> On Monday, 11 August 2014 at 20:02:38 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> >Anyway, clearly we're not understanding each other, so let me present some concrete code so that we aren't just talking past each other:
> 
> I've used your advice and implemented a range over the list as suggested, the problem being i cannot get it to pass the isForwardRange check.
> 
> Code: http://dpaste.dzfl.pl/cad89406bbcc#line-220
> 
> You'll notice the assert on line 220 fails. Any idea what i'm doing wrong?

You need to put @property on .save.


T

-- 
Valentine's Day: an occasion for florists to reach into the wallets of nominal lovers in dire need of being reminded to profess their hypothetical love for their long-forgotten.
August 13, 2014
On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> On Wed, Aug 13, 2014 at 06:31:32PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
>> On Monday, 11 August 2014 at 20:02:38 UTC, H. S. Teoh via
>> Digitalmars-d-learn wrote:
>> >Anyway, clearly we're not understanding each other, so let me present
>> >some concrete code so that we aren't just talking past each other:
>> 
>> I've used your advice and implemented a range over the list as
>> suggested, the problem being i cannot get it to pass the
>> isForwardRange check.
>> 
>> Code: http://dpaste.dzfl.pl/cad89406bbcc#line-220
>> 
>> You'll notice the assert on line 220 fails. Any idea what i'm doing
>> wrong?
>
> You need to put @property on .save.

Hmm...

    struct Result {
        public @property auto save1() {
            return this;
        }
        public auto save2() {
            return this;
        }
    }

    pragma(msg, typeof(Result.init.save1));
    pragma(msg, typeof(Result.init.save2));

This outputs:

    Result
    Result()

`Result()` looks bogus.
August 13, 2014
On Wed, Aug 13, 2014 at 07:23:30PM +0000, via Digitalmars-d-learn wrote:
> On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> >On Wed, Aug 13, 2014 at 06:31:32PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
[...]
> >>I've used your advice and implemented a range over the list as suggested, the problem being i cannot get it to pass the isForwardRange check.
> >>
> >>Code: http://dpaste.dzfl.pl/cad89406bbcc#line-220
> >>
> >>You'll notice the assert on line 220 fails. Any idea what i'm doing wrong?
> >
> >You need to put @property on .save.
> 
> Hmm...
> 
>     struct Result {
>         public @property auto save1() {
>             return this;
>         }
>         public auto save2() {
>             return this;
>         }
>     }
> 
>     pragma(msg, typeof(Result.init.save1));
>     pragma(msg, typeof(Result.init.save2));
> 
> This outputs:
> 
>     Result
>     Result()
> 
> `Result()` looks bogus.

File a bug. :-)

	https://issues.dlang.org/enter_bug.cgi


T

-- 
What is Matter, what is Mind? Never Mind, it doesn't Matter.
August 13, 2014
On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> On Wed, Aug 13, 2014 at 06:31:32PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
>> On Monday, 11 August 2014 at 20:02:38 UTC, H. S. Teoh via
>> Digitalmars-d-learn wrote:
>> >Anyway, clearly we're not understanding each other, so let me present
>> >some concrete code so that we aren't just talking past each other:
>> 
>> I've used your advice and implemented a range over the list as
>> suggested, the problem being i cannot get it to pass the
>> isForwardRange check.
>> 
>> Code: http://dpaste.dzfl.pl/cad89406bbcc#line-220
>> 
>> You'll notice the assert on line 220 fails. Any idea what i'm doing
>> wrong?
>
> You need to put @property on .save.
>
>
> T

Gah! Thanks, i need sleep. :)
August 13, 2014
On Wed, Aug 13, 2014 at 07:37:09PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
> On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> >On Wed, Aug 13, 2014 at 06:31:32PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
[...]
> >>I've used your advice and implemented a range over the list as suggested, the problem being i cannot get it to pass the isForwardRange check.
> >>
> >>Code: http://dpaste.dzfl.pl/cad89406bbcc#line-220
> >>
> >>You'll notice the assert on line 220 fails. Any idea what i'm doing wrong?
> >
> >You need to put @property on .save.
> >
> >
> >T
> 
> Gah! Thanks, i need sleep. :)

No worries, the only reason I could pinpoint this almost immediately was because I got bitten by exactly the same problem before, and it took me *hours* to figure out what was wrong. :-/


T

-- 
Never ascribe to malice that which is adequately explained by incompetence. -- Napoleon Bonaparte
August 13, 2014
On Wednesday, 13 August 2014 at 19:43:20 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> On Wed, Aug 13, 2014 at 07:37:09PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
>> On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via
>> Digitalmars-d-learn wrote:
>> >On Wed, Aug 13, 2014 at 06:31:32PM +0000, Gary Willoughby via
>> >Digitalmars-d-learn wrote:
> [...]
>> >>I've used your advice and implemented a range over the list as
>> >>suggested, the problem being i cannot get it to pass the
>> >>isForwardRange check.
>> >>
>> >>Code: http://dpaste.dzfl.pl/cad89406bbcc#line-220
>> >>
>> >>You'll notice the assert on line 220 fails. Any idea what i'm doing
>> >>wrong?
>> >
>> >You need to put @property on .save.
>> >
>> >
>> >T
>> 
>> Gah! Thanks, i need sleep. :)
>
> No worries, the only reason I could pinpoint this almost immediately was
> because I got bitten by exactly the same problem before, and it took me
> *hours* to figure out what was wrong. :-/
>
>
> T

Thinking about it why should that matter when not compiled using -property? I'm guessing the template enforces it should be a property?
August 13, 2014
On Wed, Aug 13, 2014 at 07:58:49PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
> On Wednesday, 13 August 2014 at 19:43:20 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> >On Wed, Aug 13, 2014 at 07:37:09PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
> >>On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
[...]
> >>>You need to put @property on .save.
[...]
> >>Gah! Thanks, i need sleep. :)
> >
> >No worries, the only reason I could pinpoint this almost immediately was because I got bitten by exactly the same problem before, and it took me *hours* to figure out what was wrong. :-/
> >
> >
> >T
> 
> Thinking about it why should that matter when not compiled using -property?  I'm guessing the template enforces it should be a property?

The problem is that this test is used in isForwardRange:

        static assert (is(typeof(r1.save) == R));

where R is the type of the range. So if .save is not @property, then typeof(r1.save) would be a function pointer, rather than the type of the function's return value, and so the test will fail.


T

-- 
What do you mean the Internet isn't filled with subliminal messages? What about all those buttons marked "submit"??
August 13, 2014
On Wednesday, 13 August 2014 at 20:27:29 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> On Wed, Aug 13, 2014 at 07:58:49PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
>> On Wednesday, 13 August 2014 at 19:43:20 UTC, H. S. Teoh via
>> Digitalmars-d-learn wrote:
>> >On Wed, Aug 13, 2014 at 07:37:09PM +0000, Gary Willoughby via
>> >Digitalmars-d-learn wrote:
>> >>On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via
>> >>Digitalmars-d-learn wrote:
> [...]
>> >>>You need to put @property on .save.
> [...]
>> >>Gah! Thanks, i need sleep. :)
>> >
>> >No worries, the only reason I could pinpoint this almost immediately was
>> >because I got bitten by exactly the same problem before, and it took me
>> >*hours* to figure out what was wrong. :-/
>> >
>> >
>> >T
>> 
>> Thinking about it why should that matter when not compiled using
>> -property?  I'm guessing the template enforces it should be a
>> property?
>
> The problem is that this test is used in isForwardRange:
>
>         static assert (is(typeof(r1.save) == R));
>
> where R is the type of the range. So if .save is not @property, then
> typeof(r1.save) would be a function pointer, rather than the type of the
> function's return value, and so the test will fail.

But wouldn't an & be needed to get a function pointer?
August 13, 2014
On Wed, Aug 13, 2014 at 08:52:32PM +0000, via Digitalmars-d-learn wrote:
> On Wednesday, 13 August 2014 at 20:27:29 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> >On Wed, Aug 13, 2014 at 07:58:49PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
> >>On Wednesday, 13 August 2014 at 19:43:20 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> >>>On Wed, Aug 13, 2014 at 07:37:09PM +0000, Gary Willoughby via Digitalmars-d-learn wrote:
> >>>>On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> >[...]
> >>>>>You need to put @property on .save.
> >[...]
> >>>>Gah! Thanks, i need sleep. :)
> >>>
> >>>No worries, the only reason I could pinpoint this almost >immediately
> >>was
> >>>because I got bitten by exactly the same problem before, and >it took
> >>me
> >>>*hours* to figure out what was wrong. :-/
> >>>
> >>>
> >>>T
> >>
> >>Thinking about it why should that matter when not compiled using -property?  I'm guessing the template enforces it should be a property?
> >
> >The problem is that this test is used in isForwardRange:
> >
> >        static assert (is(typeof(r1.save) == R));
> >
> >where R is the type of the range. So if .save is not @property, then typeof(r1.save) would be a function pointer, rather than the type of the function's return value, and so the test will fail.
> 
> But wouldn't an & be needed to get a function pointer?

Sorry, my bad. It's just a function, not a function pointer. The type of a function is not the same as the type of its return value (obviously).


T

-- 
Study gravitation, it's a field with a lot of potential.
August 14, 2014
On Wednesday, 13 August 2014 at 19:30:53 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> On Wed, Aug 13, 2014 at 07:23:30PM +0000, via Digitalmars-d-learn wrote:
>> On Wednesday, 13 August 2014 at 18:58:59 UTC, H. S. Teoh via
>> Digitalmars-d-learn wrote:
>> >On Wed, Aug 13, 2014 at 06:31:32PM +0000, Gary Willoughby via
>> >Digitalmars-d-learn wrote:
> [...]
>> >>I've used your advice and implemented a range over the list as
>> >>suggested, the problem being i cannot get it to pass the
>> >>isForwardRange check.
>> >>
>> >>Code: http://dpaste.dzfl.pl/cad89406bbcc#line-220
>> >>
>> >>You'll notice the assert on line 220 fails. Any idea what i'm doing
>> >>wrong?
>> >
>> >You need to put @property on .save.
>> 
>> Hmm...
>> 
>>     struct Result {
>>         public @property auto save1() {
>>             return this;
>>         }
>>         public auto save2() {
>>             return this;
>>         }
>>     }
>> 
>>     pragma(msg, typeof(Result.init.save1));
>>     pragma(msg, typeof(Result.init.save2));
>> 
>> This outputs:
>> 
>>     Result
>>     Result()
>> 
>> `Result()` looks bogus.
>
> File a bug. :-)
>
> 	https://issues.dlang.org/enter_bug.cgi

https://issues.dlang.org/show_bug.cgi?id=13293

And I see that Vladimir already reported a bug about the original problem:
https://issues.dlang.org/show_bug.cgi?id=11761
1 2
Next ›   Last »