Jump to page: 1 2
Thread overview
[dmd-beta] D2 2.058 alpha
Feb 08, 2012
Walter Bright
Feb 08, 2012
David Simcha
Feb 08, 2012
Don Clugston
Feb 08, 2012
David Simcha
Feb 08, 2012
Don Clugston
Feb 08, 2012
David Simcha
Feb 08, 2012
David Simcha
Feb 08, 2012
Jacob Carlborg
Feb 08, 2012
Jonathan M Davis
Feb 08, 2012
Don Clugston
Feb 08, 2012
David Simcha
Feb 08, 2012
Martin Nowak
Feb 08, 2012
Jesse Phillips
Feb 08, 2012
Martin Nowak
Feb 08, 2012
Jesse Phillips
Feb 08, 2012
Jesse Phillips
Feb 08, 2012
Rainer Schuetze
Feb 08, 2012
Jesse Phillips
February 08, 2012
http://ftp.digitalmars.com/dmd2beta.zip

I'm calling it an alpha because we haven't resolved the associative array issue. But I want to see if there are any others before we do a release.
February 08, 2012
On 2/8/2012 5:50 AM, Walter Bright wrote:
> http://ftp.digitalmars.com/dmd2beta.zip
>
> I'm calling it an alpha because we haven't resolved the associative
> array issue. But I want to see if there are any others before we do a
> release.
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>

Bug 7426 is still broken in cases that worked in 2.057.

struct S {
     static if(hasIndirections!(typeof(this))) {}
}

template hasIndirections(T)
{
     enum hasIndirections = hasIndirectionsImpl!(typeof(T.init.tupleof));
}

template hasIndirectionsImpl(T...)
{
     static if (!T.length)
     {
         enum hasIndirectionsImpl = false;
     }
     else
     {
         enum hasIndirectionsImpl = true;
     }
}

February 08, 2012
I don't think that should compile.  If there was anything inside the
'static if' body, it'd be wrong code.
To me, that looks like an accepts-invalid bug that's been fixed.

On 8 February 2012 14:56, David Simcha <dsimcha at gmail.com> wrote:
> On 2/8/2012 5:50 AM, Walter Bright wrote:
>>
>> http://ftp.digitalmars.com/dmd2beta.zip
>>
>> I'm calling it an alpha because we haven't resolved the associative array
>> issue. But I want to see if there are any others before we do a release.
>> _______________________________________________
>> dmd-beta mailing list
>> dmd-beta at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>>
>
> Bug 7426 is still broken in cases that worked in 2.057.
>
> struct S {
> ? ?static if(hasIndirections!(typeof(this))) {}
> }
>
> template hasIndirections(T)
> {
> ? ?enum hasIndirections = hasIndirectionsImpl!(typeof(T.init.tupleof));
> }
>
> template hasIndirectionsImpl(T...)
> {
> ? ?static if (!T.length)
> ? ?{
> ? ? ? ?enum hasIndirectionsImpl = false;
> ? ?}
> ? ?else
> ? ?{
> ? ? ? ?enum hasIndirectionsImpl = true;
>
> ? ?}
> }
>
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
February 08, 2012
Ok, I think I understand where you're coming from.  The intended use for this was to add member functions depending on the result of the static if, not member variables.  Adding member functions should in theory be legal, but figuring out whether an instantiation could add member functions is non-trivial and I think equivalent to the Halting Problem.

On Wed, Feb 8, 2012 at 9:59 AM, Don Clugston <dclugston at googlemail.com>wrote:

> I don't think that should compile.  If there was anything inside the
> 'static if' body, it'd be wrong code.
> To me, that looks like an accepts-invalid bug that's been fixed.
>
> On 8 February 2012 14:56, David Simcha <dsimcha at gmail.com> wrote:
> > On 2/8/2012 5:50 AM, Walter Bright wrote:
> >>
> >> http://ftp.digitalmars.com/dmd2beta.zip
> >>
> >> I'm calling it an alpha because we haven't resolved the associative
> array
> >> issue. But I want to see if there are any others before we do a release.
> >> _______________________________________________
> >> dmd-beta mailing list
> >> dmd-beta at puremagic.com
> >> http://lists.puremagic.com/mailman/listinfo/dmd-beta
> >>
> >
> > Bug 7426 is still broken in cases that worked in 2.057.
> >
> > struct S {
> >    static if(hasIndirections!(typeof(this))) {}
> > }
> >
> > template hasIndirections(T)
> > {
> >    enum hasIndirections = hasIndirectionsImpl!(typeof(T.init.tupleof));
> > }
> >
> > template hasIndirectionsImpl(T...)
> > {
> >    static if (!T.length)
> >    {
> >        enum hasIndirectionsImpl = false;
> >    }
> >    else
> >    {
> >        enum hasIndirectionsImpl = true;
> >
> >    }
> > }
> >
> > _______________________________________________
> > dmd-beta mailing list
> > dmd-beta at puremagic.com
> > http://lists.puremagic.com/mailman/listinfo/dmd-beta
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20120208/eae5cb21/attachment-0001.html>
February 08, 2012
On 8 February 2012 16:31, David Simcha <dsimcha at gmail.com> wrote:
> Ok, I think I understand where you're coming from.? The intended use for this was to add member functions depending on the result of the static if, not member variables.? Adding member functions should in theory be legal, but figuring out whether an instantiation could add member functions is non-trivial and I think equivalent to the Halting Problem.

I mean X.tupleof shouldn't be defined, if X is not fully defined yet.

>
>
> On Wed, Feb 8, 2012 at 9:59 AM, Don Clugston <dclugston at googlemail.com> wrote:
>>
>> I don't think that should compile. ?If there was anything inside the
>> 'static if' body, it'd be wrong code.
>> To me, that looks like an accepts-invalid bug that's been fixed.
>>
>> On 8 February 2012 14:56, David Simcha <dsimcha at gmail.com> wrote:
>> > On 2/8/2012 5:50 AM, Walter Bright wrote:
>> >>
>> >> http://ftp.digitalmars.com/dmd2beta.zip
>> >>
>> >> I'm calling it an alpha because we haven't resolved the associative
>> >> array
>> >> issue. But I want to see if there are any others before we do a
>> >> release.
>> >> _______________________________________________
>> >> dmd-beta mailing list
>> >> dmd-beta at puremagic.com
>> >> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>> >>
>> >
>> > Bug 7426 is still broken in cases that worked in 2.057.
>> >
>> > struct S {
>> > ? ?static if(hasIndirections!(typeof(this))) {}
>> > }
>> >
>> > template hasIndirections(T)
>> > {
>> > ? ?enum hasIndirections = hasIndirectionsImpl!(typeof(T.init.tupleof));
>> > }
>> >
>> > template hasIndirectionsImpl(T...)
>> > {
>> > ? ?static if (!T.length)
>> > ? ?{
>> > ? ? ? ?enum hasIndirectionsImpl = false;
>> > ? ?}
>> > ? ?else
>> > ? ?{
>> > ? ? ? ?enum hasIndirectionsImpl = true;
>> >
>> > ? ?}
>> > }
>> >
>> > _______________________________________________
>> > dmd-beta mailing list
>> > dmd-beta at puremagic.com
>> > http://lists.puremagic.com/mailman/listinfo/dmd-beta
>> _______________________________________________
>> dmd-beta mailing list
>> dmd-beta at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
>
>
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
February 08, 2012
Yeah.  Now that you point this out, I agree 100%.  Feel free to close the relevant bug report as invalid.

On Wed, Feb 8, 2012 at 11:06 AM, Don Clugston <dclugston at googlemail.com>wrote:

> On 8 February 2012 16:31, David Simcha <dsimcha at gmail.com> wrote:
> > Ok, I think I understand where you're coming from.  The intended use for this was to add member functions depending on the result of the static
> if,
> > not member variables.  Adding member functions should in theory be legal, but figuring out whether an instantiation could add member functions is non-trivial and I think equivalent to the Halting Problem.
>
> I mean X.tupleof shouldn't be defined, if X is not fully defined yet.
>
> >
> >
> > On Wed, Feb 8, 2012 at 9:59 AM, Don Clugston <dclugston at googlemail.com> wrote:
> >>
> >> I don't think that should compile.  If there was anything inside the
> >> 'static if' body, it'd be wrong code.
> >> To me, that looks like an accepts-invalid bug that's been fixed.
> >>
> >> On 8 February 2012 14:56, David Simcha <dsimcha at gmail.com> wrote:
> >> > On 2/8/2012 5:50 AM, Walter Bright wrote:
> >> >>
> >> >> http://ftp.digitalmars.com/dmd2beta.zip
> >> >>
> >> >> I'm calling it an alpha because we haven't resolved the associative
> >> >> array
> >> >> issue. But I want to see if there are any others before we do a
> >> >> release.
> >> >> _______________________________________________
> >> >> dmd-beta mailing list
> >> >> dmd-beta at puremagic.com
> >> >> http://lists.puremagic.com/mailman/listinfo/dmd-beta
> >> >>
> >> >
> >> > Bug 7426 is still broken in cases that worked in 2.057.
> >> >
> >> > struct S {
> >> >    static if(hasIndirections!(typeof(this))) {}
> >> > }
> >> >
> >> > template hasIndirections(T)
> >> > {
> >> >    enum hasIndirections =
> hasIndirectionsImpl!(typeof(T.init.tupleof));
> >> > }
> >> >
> >> > template hasIndirectionsImpl(T...)
> >> > {
> >> >    static if (!T.length)
> >> >    {
> >> >        enum hasIndirectionsImpl = false;
> >> >    }
> >> >    else
> >> >    {
> >> >        enum hasIndirectionsImpl = true;
> >> >
> >> >    }
> >> > }
> >> >
> >> > _______________________________________________
> >> > dmd-beta mailing list
> >> > dmd-beta at puremagic.com
> >> > http://lists.puremagic.com/mailman/listinfo/dmd-beta
> >> _______________________________________________
> >> dmd-beta mailing list
> >> dmd-beta at puremagic.com
> >> http://lists.puremagic.com/mailman/listinfo/dmd-beta
> >
> >
> >
> > _______________________________________________
> > dmd-beta mailing list
> > dmd-beta at puremagic.com
> > http://lists.puremagic.com/mailman/listinfo/dmd-beta
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20120208/95bc2d03/attachment.html>
February 08, 2012
...Though on second thought maybe it should have a better error message so it's clear why it doesn't work, since it wasn't at all obvious to me.  I'll change the bug report accordingly.

On Wed, Feb 8, 2012 at 11:44 AM, David Simcha <dsimcha at gmail.com> wrote:

> Yeah.  Now that you point this out, I agree 100%.  Feel free to close the relevant bug report as invalid.
>
>
> On Wed, Feb 8, 2012 at 11:06 AM, Don Clugston <dclugston at googlemail.com>wrote:
>
>> On 8 February 2012 16:31, David Simcha <dsimcha at gmail.com> wrote:
>> > Ok, I think I understand where you're coming from.  The intended use for this was to add member functions depending on the result of the static
>> if,
>> > not member variables.  Adding member functions should in theory be
>> legal,
>> > but figuring out whether an instantiation could add member functions is non-trivial and I think equivalent to the Halting Problem.
>>
>> I mean X.tupleof shouldn't be defined, if X is not fully defined yet.
>>
>> >
>> >
>> > On Wed, Feb 8, 2012 at 9:59 AM, Don Clugston <dclugston at googlemail.com> wrote:
>> >>
>> >> I don't think that should compile.  If there was anything inside the
>> >> 'static if' body, it'd be wrong code.
>> >> To me, that looks like an accepts-invalid bug that's been fixed.
>> >>
>> >> On 8 February 2012 14:56, David Simcha <dsimcha at gmail.com> wrote:
>> >> > On 2/8/2012 5:50 AM, Walter Bright wrote:
>> >> >>
>> >> >> http://ftp.digitalmars.com/dmd2beta.zip
>> >> >>
>> >> >> I'm calling it an alpha because we haven't resolved the associative
>> >> >> array
>> >> >> issue. But I want to see if there are any others before we do a
>> >> >> release.
>> >> >> _______________________________________________
>> >> >> dmd-beta mailing list
>> >> >> dmd-beta at puremagic.com
>> >> >> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>> >> >>
>> >> >
>> >> > Bug 7426 is still broken in cases that worked in 2.057.
>> >> >
>> >> > struct S {
>> >> >    static if(hasIndirections!(typeof(this))) {}
>> >> > }
>> >> >
>> >> > template hasIndirections(T)
>> >> > {
>> >> >    enum hasIndirections =
>> hasIndirectionsImpl!(typeof(T.init.tupleof));
>> >> > }
>> >> >
>> >> > template hasIndirectionsImpl(T...)
>> >> > {
>> >> >    static if (!T.length)
>> >> >    {
>> >> >        enum hasIndirectionsImpl = false;
>> >> >    }
>> >> >    else
>> >> >    {
>> >> >        enum hasIndirectionsImpl = true;
>> >> >
>> >> >    }
>> >> > }
>> >> >
>> >> > _______________________________________________
>> >> > dmd-beta mailing list
>> >> > dmd-beta at puremagic.com
>> >> > http://lists.puremagic.com/mailman/listinfo/dmd-beta
>> >> _______________________________________________
>> >> dmd-beta mailing list
>> >> dmd-beta at puremagic.com
>> >> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>> >
>> >
>> >
>> > _______________________________________________
>> > dmd-beta mailing list
>> > dmd-beta at puremagic.com
>> > http://lists.puremagic.com/mailman/listinfo/dmd-beta
>> _______________________________________________
>> dmd-beta mailing list
>> dmd-beta at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20120208/cc89a84f/attachment-0001.html>
February 08, 2012
On 8 feb 2012, at 17:44, David Simcha wrote:

> Yeah.  Now that you point this out, I agree 100%.  Feel free to close the relevant bug report as invalid.
> 
> On Wed, Feb 8, 2012 at 11:06 AM, Don Clugston <dclugston at googlemail.com> wrote: On 8 February 2012 16:31, David Simcha <dsimcha at gmail.com> wrote:
> > Ok, I think I understand where you're coming from.  The intended use for this was to add member functions depending on the result of the static if, not member variables.  Adding member functions should in theory be legal, but figuring out whether an instantiation could add member functions is non-trivial and I think equivalent to the Halting Problem.
> 
> I mean X.tupleof shouldn't be defined, if X is not fully defined yet.
> 
> >
> >
> > On Wed, Feb 8, 2012 at 9:59 AM, Don Clugston <dclugston at googlemail.com> wrote:
> >>
> >> I don't think that should compile.  If there was anything inside the
> >> 'static if' body, it'd be wrong code.
> >> To me, that looks like an accepts-invalid bug that's been fixed.
> >>
> >> On 8 February 2012 14:56, David Simcha <dsimcha at gmail.com> wrote:
> >> > On 2/8/2012 5:50 AM, Walter Bright wrote:
> >> >>
> >> >> http://ftp.digitalmars.com/dmd2beta.zip
> >> >>
> >> >> I'm calling it an alpha because we haven't resolved the associative
> >> >> array
> >> >> issue. But I want to see if there are any others before we do a
> >> >> release.
> >> >> _______________________________________________
> >> >> dmd-beta mailing list
> >> >> dmd-beta at puremagic.com
> >> >> http://lists.puremagic.com/mailman/listinfo/dmd-beta
> >> >>
> >> >
> >> > Bug 7426 is still broken in cases that worked in 2.057.
> >> >
> >> > struct S {
> >> >    static if(hasIndirections!(typeof(this))) {}
> >> > }
> >> >
> >> > template hasIndirections(T)
> >> > {
> >> >    enum hasIndirections = hasIndirectionsImpl!(typeof(T.init.tupleof));
> >> > }
> >> >
> >> > template hasIndirectionsImpl(T...)
> >> > {
> >> >    static if (!T.length)
> >> >    {
> >> >        enum hasIndirectionsImpl = false;
> >> >    }
> >> >    else
> >> >    {
> >> >        enum hasIndirectionsImpl = true;
> >> >
> >> >    }
> >> > }


But if you put the "static if"-statement after all fields, shouldn't that be enough to have the full size of the struct. Of course it could be hard for the compiler to know that there are no fields after the "static if"-statement. Maybe the compiler could calculate the size incrementally.

-- 
/Jacob Carlborg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20120208/3cdbd21f/attachment.html>
February 08, 2012
On Wednesday, February 08, 2012 18:15:30 Jacob Carlborg wrote:
> But if you put the "static if"-statement after all fields, shouldn't that be enough to have the full size of the struct. Of course it could be hard for the compiler to know that there are no fields after the "static if"-statement. Maybe the compiler could calculate the size incrementally.

That could cause big problems if the static if weren't after all of the member variables. You could have multiple static ifs, each of which ended up with a different size for the type, if there are member variables declared between them. We _could_ make it give an error if you then added a member variable after such a static if, but that's probably getting a bit complicated, since more state is necessary. So, it's probably better to just disallow such static ifs.

- Jonathan M Davis
February 08, 2012
On 8 February 2012 18:57, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> On Wednesday, February 08, 2012 18:15:30 Jacob Carlborg wrote:
>> But if you put the "static if"-statement after all fields, shouldn't that be enough to have the full size of the struct. Of course it could be hard for the compiler to know that there are no fields after the "static if"-statement. Maybe the compiler could calculate the size incrementally.
>
> That could cause big problems if the static if weren't after all of the member variables. You could have multiple static ifs, each of which ended up with a different size for the type, if there are member variables declared between them. We _could_ make it give an error if you then added a member variable after such a static if, but that's probably getting a bit complicated, since more state is necessary. So, it's probably better to just disallow such static ifs.

More specifically, it's not static if which is the problem, it's that .tupleof shouldn't be legal until all members have been declared. BTW if a static if body doesn't contain any declarations, there's not much it can contain that's meaningful!

I think that based on the error message issue, the bug should stay open, but not as a regression.
« First   ‹ Prev
1 2