Re: opDispatch and template parameters
Simen kjaeraas wrote: Guillaume B. guillaume.b.s...@spam.ca wrote: Hi, Is this usage of opDispatch supposed to work: module test.d; import std.stdio; struct DispatchTest { void opDispatch(string name, string otherName)() { writeln(name, :, otherName); } } void main() { DispatchTest t; //t.testName!(testOtherName)(); t.opDispatch!(testName, testOtherName)(); } [...] Sorry for not noticing this post before. This is not a bug. The correct way to do what you want is this: module foo; import std.stdio; struct test { template opDispatch( string name ) { void opDispatch( string other )( ) { writeln( name, , , other ); } } } void main( ) { test t; t.foo!( Hey! )( ); } Wow! That's a nice trick! Seems like I'll have to be carefull when defining opDispatch! Guillaume
Re: opDispatch and template parameters
Oh, well: http://d.puremagic.com/issues/show_bug.cgi?id=4856 Guillaume Guillaume B. wrote: Hi, Is this usage of opDispatch supposed to work: module test.d; import std.stdio; struct DispatchTest { void opDispatch(string name, string otherName)() { writeln(name, :, otherName); } } void main() { DispatchTest t; //t.testName!(testOtherName)(); t.opDispatch!(testName, testOtherName)(); } This compiles fine but if I remove the commented line, dmd (v2.048) tells me: test.d(13): Error: template instance opDispatch!(testName) does not match template declaration opDispatch(string name,string otherName) The error seems OK for a normal function, but for opDispatch, it seems limiting to me. Is this a bug? Here's an other, similar, test: module test.d; import std.stdio; struct DispatchTest { void opDispatch(string name, T)(T t) { writeln(name, :, T.stringof); } } void main() { DispatchTest t; //t.testName!(DispatchTest)(t); t.testName(t); } Which gives, when uncommenting: test.d(13): Error: template instance opDispatch!(testName) does not match template declaration opDispatch(string name,T) So bug or not? Guillaume
opDispatch and template parameters
Hi, Is this usage of opDispatch supposed to work: module test.d; import std.stdio; struct DispatchTest { void opDispatch(string name, string otherName)() { writeln(name, :, otherName); } } void main() { DispatchTest t; //t.testName!(testOtherName)(); t.opDispatch!(testName, testOtherName)(); } This compiles fine but if I remove the commented line, dmd (v2.048) tells me: test.d(13): Error: template instance opDispatch!(testName) does not match template declaration opDispatch(string name,string otherName) The error seems OK for a normal function, but for opDispatch, it seems limiting to me. Is this a bug? Here's an other, similar, test: module test.d; import std.stdio; struct DispatchTest { void opDispatch(string name, T)(T t) { writeln(name, :, T.stringof); } } void main() { DispatchTest t; //t.testName!(DispatchTest)(t); t.testName(t); } Which gives, when uncommenting: test.d(13): Error: template instance opDispatch!(testName) does not match template declaration opDispatch(string name,T) So bug or not? Guillaume
Re: This just in: authorless TDPL becomes collector's edition
Got mine today from Amazon Canada: collector's edition too. I'll start reading it soon! Guillaume Mike James wrote: Got my collectors item delivered today from Amazon UK. Looks good. I like the bonus of being able to download a PDF version of TDPL. Thanks for all the hard work Andrei. -=mike=- Andrei Alexandrescu seewebsiteforem...@erdani.org wrote in message news:hu3hq6$2f0...@digitalmars.com... Due to a pretty odd mistake at the printer, the first 1000 copies of TDPL will not have the name of the author on their cover. (The name still appears on the back cover and the spine.) The history of printing is rife with rare printing mistakes that have become collector's editions. Preorder now to be among the first 1000 readers who get the authorless TDPL edition. Andrei
Re: I'm holding it in my hands
Andrei Alexandrescu wrote: http://erdani.com Don't worry, it's SFW :o). Andrei I've already preordered via amazon in Canada but it doesn't seem that it will be shipped before June 14... I'll have to wait! Guillaume
Re: Can D be cute? (Qt)
Justin Johansson wrote: May I ask if others on this NG are across Qt and D might be capable of slotting into some of this market for cross-platform GUI development. That would be QtD: http://www.dsource.org/projects/qtd Guillaume
Re: dmd beta mailing list
Guillaume B. wrote: I prefer to read everything in my news reader. Is it possible to add the following malling lists from http://lists.puremagic.com/ to gmane? ( http://gmane.org/subscribe.php ) - dmd-beta - dmd-concurrency - phobos - dmd-internals Some lists for D are already on gmane so it would be nice if they could all be there. Hi
Re: dmd beta mailing list
Leandro Lucarella wrote: Guillaume B., el 4 de enero a las 19:10 me escribiste: I prefer to read everything in my news reader. Is it possible to add the following malling lists from http://lists.puremagic.com/ to gmane? ( http://gmane.org/subscribe.php ) - dmd-beta - dmd-concurrency - phobos - dmd-internals Some lists for D are already on gmane so it would be nice if they could all be there. Yes, just do it yourself: http://gmane.org/subscribe.php Hi, I know I can do it myself but I wanted to be sure it was OK since, on gmane, it's written: [...] ask the people on the mailing list first. Or at least the mailing list administrator. Then you fill out the subscription page. So is it OK for Brad and/or Walter? Thanks, Guillaume
Re: The Final(ize) Challenge
Andrei Alexandrescu wrote: For starters, I'd like to present you with the following challenge. Given any class C, e.g.: class C { void foo(int) { ... } int bar(string) { ... } } define a template class Finalize(T) such that Finalize!(C) is the same as the following hand-written class: final class FinalizeC : C { final void foo(int a) { return super.foo(a); } final int bar(string a) { return super.bar(a); } } Finalize is cool when you need some functionality from an exact class and you don't want to pay indirect calls throughout. All calls through Finalize!(C)'s methods will resolve to static calls. Hi, I don't fully understand the uses of Finalize!(C)... But for logging (or timing), this kind of template could be useful... it think!... Anyway, something like this: class MagicLog(T) : T { // D Magic... } Could turn a class like this: class C { int foo() { ... } } to this: class MagicLogC { int foo() { Log.write(Entering foo()); scope(success) Log.write(Leaving foo(): success); scope(failure) Log.write(Leaving foo(): failure); return super.foo(); } } And then, somewhere else: version(WithMagicLog) { C c = new MagicLog!(C); // With logging } else { C c = new C; // Full speed, no logging } int i = c.foo(); Seems pretty useful to me! :) The only problem is writing the MagicLog class. Guillaume B.