Re: std.mixins

2010-09-01 Thread Torarin
TDPL says it should work for any type. http://d.puremagic.com/issues/show_bug.cgi?id=3382 2010/9/1 Nick Sabalausky a...@a.a: dsimcha dsim...@yahoo.com wrote in message news:i5jtdn$1g4...@digitalmars.com... Isn't this a core language feature that's in the spec but is only currently

Re: std.mixins

2010-09-01 Thread Simen kjaeraas
Philippe Sigaud philippe.sig...@gmail.com wrote: I also have a template that gets the list of all members of an aggregate type (classes, structs and, well, modules, in a way), even the constructors, even the overloaded members, separated by type, and list them with their names and associated

Re: std.mixins

2010-09-01 Thread Nick Sabalausky
Torarin torar...@gmail.com wrote in message news:mailman.31.1283345570.858.digitalmar...@puremagic.com... 2010/9/1 Nick Sabalausky a...@a.a: dsimcha dsim...@yahoo.com wrote in message news:i5jtdn$1g4...@digitalmars.com... Isn't this a core language feature that's in the spec but is only

Re: std.mixins

2010-09-01 Thread Philippe Sigaud
On Wed, Sep 1, 2010 at 20:59, Nick Sabalausky a...@a.a wrote: Torarin torar...@gmail.com wrote in messageTDPL says it should work for any type. http://d.puremagic.com/issues/show_bug.cgi?id=3382 /me squeals with excitement like a schoolgirl Any type, really? Even the basic built-in types,

Re: std.mixins

2010-09-01 Thread Torarin
It says: If a.fun(b, c, d) is seen but fun is not a member of a's type, D rewrites that as fun(a, b, c, d) and tries that as well. So I guess it's possible it won't work with numerical types because they can never have members. 2010/9/1 Philippe Sigaud philippe.sig...@gmail.com: On Wed, Sep 1,

Re: std.mixins

2010-09-01 Thread Philippe Sigaud
On Wed, Sep 1, 2010 at 15:25, Simen kjaeraas simen.kja...@gmail.com wrote: Philippe Sigaud philippe.sig...@gmail.com wrote: I also have a template that gets the list of all members of an aggregate type (classes, structs and, well, modules, in a way), even the constructors, even the

Re: std.mixins

2010-09-01 Thread Philippe Sigaud
On Wed, Sep 1, 2010 at 21:47, Torarin torar...@gmail.com wrote: It says: If a.fun(b, c, d) is seen but fun is not a member of a's type, D rewrites that as fun(a, b, c, d) and tries that as well. So I guess it's possible it won't work with numerical types because they can never have members.

Re: std.mixins

2010-09-01 Thread Torarin
2010/9/1 Philippe Sigaud philippe.sig...@gmail.com: I just tried this:     int i;     writeln(i.max); // writes int.max ! So it seems you can access the type properties through a value of that type. Man, I learnt two new things in two minutes... Yay, looks pretty good, then! :)

Re: std.mixins

2010-09-01 Thread Nick Sabalausky
Torarin torar...@gmail.com wrote in message news:mailman.37.1283370434.858.digitalmar...@puremagic.com... It says: If a.fun(b, c, d) is seen but fun is not a member of a's type, D rewrites that as fun(a, b, c, d) and tries that as well. So I guess it's possible it won't work with numerical

Re: std.mixins

2010-09-01 Thread Philippe Sigaud
On Wed, Sep 1, 2010 at 22:18, Nick Sabalausky a...@a.a wrote: Regression(2.020) Array member call syntax can't find matches in current class http://d.puremagic.com/issues/show_bug.cgi?id=4525 When I converted some D1 code to D2 recently, I actually had to *remove* many of my

Re: std.mixins

2010-09-01 Thread Jacob Carlborg
On 2010-08-31 03:04, dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code for mixing into classes and and structs. I've started to prototype it (http://dsource.org/projects/scrapple

Re: std.mixins

2010-09-01 Thread Jacob Carlborg
On 2010-09-01 14:52, Torarin wrote: TDPL says it should work for any type. http://d.puremagic.com/issues/show_bug.cgi?id=3382 2010/9/1 Nick Sabalauskya...@a.a: dsimchadsim...@yahoo.com wrote in message news:i5jtdn$1g4...@digitalmars.com... Isn't this a core language feature that's in the

Re: std.mixins

2010-09-01 Thread Nick Sabalausky
Jacob Carlborg d...@me.com wrote in message news:i5mg57$2sh...@digitalmars.com... On 2010-09-01 14:52, Torarin wrote: TDPL says it should work for any type. http://d.puremagic.com/issues/show_bug.cgi?id=3382 2010/9/1 Nick Sabalauskya...@a.a: dsimchadsim...@yahoo.com wrote in message

Re: std.mixins

2010-09-01 Thread bearophile
Nick Sabalausky: But I also remember a certain someone (me!...plus some others) saying that .1 and 1. float literals are completely worthless and in the face of ambiguity with *useful* things, they need to DIE DIE DIE!!! See the second part of this (closed) enhancement request of mine :-)

Re: std.mixins

2010-09-01 Thread Nick Sabalausky
bearophile bearophileh...@lycos.com wrote in message news:i5mhnk$301...@digitalmars.com... Nick Sabalausky: But I also remember a certain someone (me!...plus some others) saying that .1 and 1. float literals are completely worthless and in the face of ambiguity with *useful* things, they

Re: std.mixins

2010-08-31 Thread Jacob Carlborg
On 2010-08-31 05:17, Andrei Alexandrescu wrote: On 8/30/10 20:04 PDT, dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code for mixing into classes and and structs. I've started

Re: std.mixins

2010-08-31 Thread Jacob Carlborg
On 2010-08-31 05:49, dsimcha wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article On 8/30/10 20:04 PDT, dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate

Re: std.mixins

2010-08-31 Thread Denis Koroskin
On Tue, 31 Aug 2010 19:13:17 +0400, Jacob Carlborg d...@me.com wrote: On 2010-08-31 05:17, Andrei Alexandrescu wrote: On 8/30/10 20:04 PDT, dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed

Re: std.mixins

2010-08-31 Thread Lutger
dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code for mixing into classes and and structs. I've started to prototype it (http://dsource.org/projects/scrapple/browser/trunk

Re: std.mixins

2010-08-31 Thread dsimcha
== Quote from Lutger (lutger.blijdest...@gmail.com)'s article Instead of std.mixins, perhaps it is better to fold the code with std.typecons or create new modules as needed (std.pattern?). I initially thought std.mixins would be a good idea, since it would be a one-stop shop for all kinds

Re: std.mixins

2010-08-31 Thread Lutger
dsimcha wrote: ... My suggestion is to include a mixin for unrolling loops. I thought about this. Simple loop unrolling doesn't seem like a very useful optimization on modern hardware because branch prediction and pipelining have gotten so good. It can still be useful if you also change

Re: std.mixins

2010-08-31 Thread BCS
Hello dsimcha, == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article On 8/30/10 20:04 PDT, dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code for mixing

Re: std.mixins

2010-08-31 Thread Nick Sabalausky
Lutger lutger.blijdest...@gmail.com wrote in message news:i5jiap$rv...@digitalmars.com... dsimcha wrote: ... My suggestion is to include a mixin for unrolling loops. I thought about this. Simple loop unrolling doesn't seem like a very useful optimization on modern hardware because

Re: std.mixins

2010-08-31 Thread Lutger
Nick Sabalausky wrote: Lutger lutger.blijdest...@gmail.com wrote in message news:i5jiap$rv...@digitalmars.com... dsimcha wrote: ... My suggestion is to include a mixin for unrolling loops. I thought about this. Simple loop unrolling doesn't seem like a very useful optimization on

Re: std.mixins

2010-08-31 Thread dsimcha
== Quote from Lutger (lutger.blijdest...@gmail.com)'s article Nick Sabalausky wrote: Lutger lutger.blijdest...@gmail.com wrote in message news:i5jiap$rv...@digitalmars.com... dsimcha wrote: ... My suggestion is to include a mixin for unrolling loops. I thought about this. Simple

Re: std.mixins

2010-08-31 Thread Nick Sabalausky
Lutger lutger.blijdest...@gmail.com wrote in message news:i5jmlc$13l...@digitalmars.com... Nick Sabalausky wrote: Lutger lutger.blijdest...@gmail.com wrote in message news:i5jiap$rv...@digitalmars.com... dsimcha wrote: It can still be useful if you also change the loop body a little, for

Re: std.mixins

2010-08-31 Thread bearophile
dsimcha: I thought about this. Simple loop unrolling doesn't seem like a very useful optimization on modern hardware because branch prediction and pipelining have gotten so good. It can still be useful if you also change the loop body a little, for example using multiple accumulators to

Re: std.mixins

2010-08-31 Thread Lutger
Nick Sabalausky wrote: Lutger lutger.blijdest...@gmail.com wrote in message news:i5jmlc$13l...@digitalmars.com... Nick Sabalausky wrote: Lutger lutger.blijdest...@gmail.com wrote in message news:i5jiap$rv...@digitalmars.com... dsimcha wrote: It can still be useful if you also change the

Re: std.mixins

2010-08-31 Thread dsimcha
== Quote from Philippe Sigaud (philippe.sig...@gmail.com)'s article std.typecons is full of good stuff. I learnt quite a lot reading it. The Any code gave many hours of reading, compiling the resulting code in my head, so to say. Then I went a little mad ;) My initial suggestion for your OP

Re: std.mixins

2010-08-31 Thread Lutger
Philippe Sigaud wrote: ... I want this to work or something like it, is it possible? enum test = [1,2, 3]; foreach(i; 0..test.length) { pragma(msg, to!string(test[i]) ); } Well, 0..someEnum is not recognized by the compiler. The workaround is to create a typetuple of the correct

Re: std.mixins

2010-08-31 Thread Philippe Sigaud
On Wed, Sep 1, 2010 at 00:05, Lutger lutger.blijdest...@gmail.com wrote: wtf it works! That's a cool trick / workaround, thanks. That'd be cool if this worked too: foreach(i,_; test) // since test is iterable or even: foreach(i,_; typeof(test)) // int[3] - consider it as (int,int,int) and

Re: std.mixins

2010-08-31 Thread Jonathan M Davis
On Tuesday, August 31, 2010 14:49:43 dsimcha wrote: Isn't this a core language feature that's in the spec but is only currently implemented for arrays? I thought eventually uniform function call syntax was coming for classes and structs, too. There are people who keep asking for it, but as

Re: std.mixins

2010-08-31 Thread bearophile
Lutger: wtf it works! That's a cool trick / workaround, thanks. See bug 4085 Bye, bearophile

Re: std.mixins

2010-08-31 Thread Nick Sabalausky
dsimcha dsim...@yahoo.com wrote in message news:i5jtdn$1g4...@digitalmars.com... Isn't this a core language feature that's in the spec but is only currently implemented for arrays? I thought eventually uniform function call syntax was coming for classes and structs, too. I've been

Re: std.mixins

2010-08-30 Thread dsimcha
== Quote from Nick Sabalausky (a...@a.a)'s article dsimcha dsim...@yahoo.com wrote in message news:i5hkea$2su...@digitalmars.com... I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code

Re: std.mixins

2010-08-30 Thread Nick Sabalausky
dsimcha dsim...@yahoo.com wrote in message news:i5hkea$2su...@digitalmars.com... I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code for mixing into classes and and structs. I've started

Re: std.mixins

2010-08-30 Thread Andrei Alexandrescu
On 8/30/10 20:04 PDT, dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code for mixing into classes and and structs. I've started to prototype it (http://dsource.org/projects/scrapple

Re: std.mixins

2010-08-30 Thread Andrei Alexandrescu
On 8/30/10 20:04 PDT, dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code for mixing into classes and and structs. I've started to prototype it (http://dsource.org/projects/scrapple

Re: std.mixins

2010-08-30 Thread Nick Sabalausky
dsimcha dsim...@yahoo.com wrote in message news:i5hs3o$9e...@digitalmars.com... == Quote from Nick Sabalausky (a...@a.a)'s article Definitely trace and traceVal/traceValCT from my lib: http://www.dsource.org/projects/semitwist/browser/trunk/src/semitwist/util/mixins.d Every time I work on D

Re: std.mixins

2010-08-30 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article On 8/30/10 20:04 PDT, dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code for mixing into classes

Re: std.mixins

2010-08-30 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article On 8/30/10 20:04 PDT, dsimcha wrote: I've been toying for a long time with the idea of a std.mixins for Phobos that would contain meta-implementations of commonly needed boilerplate code for mixing into classes