Re: Applying a tuple to a function (and more)

2010-09-20 Thread Philippe Sigaud
On Sun, Sep 19, 2010 at 18:33, Juanjo Alvarez juan...@gmail.com wrote: Philippe Sigaud wrote: What languages are you used to? You seem to do quite well with genericity :) What I've done profesionally and personally in the last year would be 90% Python, 5% Java and 5% C++. So yes, since

Re: Applying a tuple to a function (and more)

2010-09-19 Thread Juanjo Alvarez
Philippe Sigaud wrote: String mixins are quite powerful, if a bit clunky at times. Both true, for what I'm seeing of them. See also __traits(getMember, ...) http://digitalmars.com/d/2.0/traits.html (look for getMember) Nice, with getMembers I could redesign again my test code for using

Re: Applying a tuple to a function (and more)

2010-09-19 Thread Philippe Sigaud
instead of a virtual function, but I'll keep the current design because is simpler for me (I'm still adapting my brain to all this genericity). What languages are you used to? You seem to do quite well with genericity :) On my current implementation with functions I still have a doubt:

Re: Applying a tuple to a function (and more)

2010-09-19 Thread Juanjo Alvarez
Philippe Sigaud wrote: What languages are you used to? You seem to do quite well with genericity :) What I've done profesionally and personally in the last year would be 90% Python, 5% Java and 5% C++. So yes, since Python is like a D with an uberauto and everything being runtime templates

Re: Applying a tuple to a function (and more)

2010-09-19 Thread bearophile
Philippe Sigaud: Recently, bug 2800 was corrected and you can also directly access a tuple's fields by indexing: double d = tup[1]; // or simply: auto d = tup[1]; This program doesn't work: import std.typecons; void main() { auto t = tuple(42, 3.14); double d = t[1]; } And I

Re: Applying a tuple to a function (and more)

2010-09-19 Thread bearophile
Juanjo Alvarez: But if I move the tuple definition to another file (urls.d) the compiler gives me the error: It seems a compiler bug. If not already present it probably needs to be added. Is there any other way to iterate over a tuple with values of different tuples? You may use a

Re: Applying a tuple to a function (and more)

2010-09-19 Thread bearophile
This program doesn't work: import std.typecons; void main() { auto t = tuple(42, 3.14); double d = t[1]; } And I think bug 2800 is unrelated: http://d.puremagic.com/issues/show_bug.cgi?id=2800 But now I have seen this: http://www.dsource.org/projects/phobos/changeset/2018

Applying a tuple to a function (and more)

2010-09-18 Thread Juanjo Alvarez
Hi, I've just arrived to D 2.0 and after reading Andrei's book I'm loving everything I'm seeing (except the bugs, of course). I wanted to ask how these would be done, because I can't find how to do it: 1. Having the strings, defined at compile time, MyClass and mymethod, how could I could I get

Re: Applying a tuple to a function (and more)

2010-09-18 Thread Philippe Sigaud
On Sat, Sep 18, 2010 at 19:59, Juanjo Alvarez juan...@gmail.com wrote: I wanted to ask how these would be done, because I can't find how to do it: 1. Having the strings, defined at compile time, MyClass and mymethod, how could I could I get to a delegate to MyClass.mymethod? You can insert

Re: Applying a tuple to a function (and more)

2010-09-18 Thread Juanjo Alvarez
Philippe Sigaud wrote: 1. Having the strings, defined at compile time, MyClass and mymethod, how could I could I get to a delegate to MyClass.mymethod? You can insert them in a piece of code as a string, and then mix it in: enum string code = auto deleg = ~ className ~ . ~ methodName ~

Re: Applying a tuple to a function (and more)

2010-09-18 Thread Philippe Sigaud
On Sun, Sep 19, 2010 at 03:43, Juanjo Alvarez juan...@gmail.com wrote: enum string code = auto deleg = ~ className ~ . ~ methodName ~ ;; // auto deleg = MyClass.mymethod; mixin(code); // created deleg, you're good to go. I tried it and worked like a charm (but I've changed my code so