Semantics of @disable

2010-04-19 Thread bearophile
Is this how @disable is supposed to work (D2 code)? Is overriding a disabled function meaningful? import std.c.stdio: puts; class A { void foo() { puts(A.foo()); } } class B : A { //@disable override void foo(); // Linker error @disable override void foo() { puts(B.foo()); }; // OK

Re: metaprogramming question

2010-04-19 Thread fawcett
On 10-04-19 01:31 AM, BCS wrote: Hello Justin Spahr-Summers, On Mon, 19 Apr 2010 00:12:28 + (UTC), Graham Fawcett fawc...@uwindsor.ca wrote: Hi folks, I'd like to wrap a family of C functions that look like this: gboolean fooXXX(arg1, ..., argN, GError** err) Their signatures and

templates

2010-04-19 Thread Ellery Newcomer
Hello. Say I have a [struct] template T, which takes a param S. Any T!(S) satisfies a certain template constraint W, so I can use any T!(S) the same way. I want to be able to store heterogeneous T!(S) in a single list. Is there any good way to express the type for this?

Re: templates

2010-04-19 Thread bearophile
Ellery Newcomer: Say I have a [struct] template T, which takes a param S. Any T!(S) satisfies a certain template constraint W, so I can use any T!(S) the same way. I want to be able to store heterogeneous T!(S) in a single list. Is there any good way to express the type for this? In D

Re: templates

2010-04-19 Thread Steven Schveighoffer
On Mon, 19 Apr 2010 14:16:03 -0400, Ellery Newcomer ellery-newco...@utulsa.edu wrote: Hello. Say I have a [struct] template T, which takes a param S. Any T!(S) satisfies a certain template constraint W, so I can use any T!(S) the same way. I want to be able to store heterogeneous T!(S) in

Re: templates

2010-04-19 Thread Steven Schveighoffer
On Mon, 19 Apr 2010 15:16:46 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Mon, 19 Apr 2010 14:16:03 -0400, Ellery Newcomer ellery-newco...@utulsa.edu wrote: Hello. Say I have a [struct] template T, which takes a param S. Any T!(S) satisfies a certain template constraint W,

Re: templates

2010-04-19 Thread Ali Çehreli
Ellery Newcomer wrote: I want to be able to store heterogeneous T!(S) in a single list std.boxer or std.variant may be useful: http://digitalmars.com/d/2.0/phobos/std_boxer.html http://digitalmars.com/d/2.0/phobos/std_variant.html Ali

Re: Code speed and C++

2010-04-19 Thread bearophile
Joseph Wakeling: I took a little time last night and wrote up a C++ version that I'll take a look at this, I was away for few days. Bye, bearophile

Re: templates

2010-04-19 Thread Philippe Sigaud
On Mon, Apr 19, 2010 at 21:20, Steven Schveighoffer schvei...@yahoo.comwrote: Here is a quick-and-dirty solution, if you don't mind using classes/interfaces. (snip) I'm not used to using interfaces in this way. What become the stored T values when you cast the classes into IW to construct

Re: templates

2010-04-19 Thread Philippe Sigaud
On Mon, Apr 19, 2010 at 21:52, Ali Çehreli acehr...@yahoo.com wrote: Ellery Newcomer wrote: I want to be able to store heterogeneous T!(S) in a single list std.boxer or std.variant may be useful: http://digitalmars.com/d/2.0/phobos/std_boxer.html

Re: templates

2010-04-19 Thread Steven Schveighoffer
On Mon, 19 Apr 2010 16:52:40 -0400, Philippe Sigaud philippe.sig...@gmail.com wrote: On Mon, Apr 19, 2010 at 21:20, Steven Schveighoffer schvei...@yahoo.comwrote: Here is a quick-and-dirty solution, if you don't mind using classes/interfaces. (snip) I'm not used to using interfaces

Re: templates

2010-04-19 Thread bearophile
Steven Schveighoffer: What I had in mind was: struct S { int foo(int x) { return x * 2; } } struct S2 { int foo(int x) { return x + 2; } } void main() { S s1; S2 s2; IW[] ws; ws ~= makeW(s1); ws ~= makeW(s2); assert(ws[0].foo(3) == 6);

Re: templates

2010-04-19 Thread Ellery Newcomer
Won't the union balloon Wrapper's size to always be that of the largest inner struct that you use?

Re: templates

2010-04-19 Thread Ellery Newcomer
On 04/19/2010 02:16 PM, Steven Schveighoffer wrote: What you are looking for is a conversion from compile-time interface to runtime interface. The only drawback is, you can't go backwards (from a runtime interface to a compile-time). That hurts. The thing is, I'm eventually going to need to

Re: templates

2010-04-19 Thread bearophile
Ellery Newcomer: Won't the union balloon Wrapper's size to always be that of the largest inner struct that you use? Yes, all items in an array must have the same size. If you want items of different size you have to add a level of indirection, storing inside the array pointers to the

ctfe library

2010-04-19 Thread Ellery Newcomer
Are there any good libraries for ctfe/code generation? I don't know, things like parsing support for compile time strings, string formatting, type - string My project seems to be growing ctfe, and it's all horribly hacky and ugly code.

Re: templates

2010-04-19 Thread BLS
On 19/04/2010 20:16, Ellery Newcomer wrote: Hello. Say I have a [struct] template T, which takes a param S. Any T!(S) satisfies a certain template constraint W, so I can use any T!(S) the same way. I want to be able to store heterogeneous T!(S) in a single list. Is there any good way to

Re: templates

2010-04-19 Thread Steven Schveighoffer
BLS Wrote: On 19/04/2010 20:16, Ellery Newcomer wrote: Hello. Say I have a [struct] template T, which takes a param S. Any T!(S) satisfies a certain template constraint W, so I can use any T!(S) the same way. I want to be able to store heterogeneous T!(S) in a single list. Is there

Re: templates

2010-04-19 Thread bearophile
Ellery Newcomer: Won't the union balloon Wrapper's size to always be that of the largest inner struct that you use? Beside using the array of struct-enums, or using an array of pointers I've explained in the other answer, there are other solutions, but they are even more complex, there are