Re: Conditional compilation

2013-06-08 Thread Chris Nicholson-Sauls
There is the aforementioned extern(system), which is probably your best bet. But I'm wondering if your design could seperate the connection to IUnknown for non-Windows builds? Something like this: version(Windows) interface _Inter_ : IUnknown {} else interface _Inter_ {} // later interface

Re: Strange output

2013-06-08 Thread Daemon
On Friday, 7 June 2013 at 20:06:32 UTC, H. S. Teoh wrote: On Fri, Jun 07, 2013 at 09:10:53PM +0200, Daemon wrote: The following program is supposed to print out only numbers that are less than 5, yet the number 63 gets printed. On Fri, Jun 07, 2013 at 09:14:00PM +0200, Daemon wrote: >auto de

Re: Traits: getting all *public* members of a class?

2013-06-08 Thread Q
On Saturday, 8 June 2013 at 14:06:32 UTC, Andrej Mitrovic wrote: On Saturday, 8 June 2013 at 13:57:13 UTC, Q wrote: Hi there, I want to iterate over all the public members of a class. It is a known problem. The workaround is to use is(typeof()): void main() { foreach (mem; __traits(allMem

Re: Traits: getting all *public* members of a class?

2013-06-08 Thread Adam D. Ruppe
You could probably throw in a traits(compiles) right above. foreach(...) { // or maybe compiles, getProtection(getMember)) static if(__traits(compiles, __traits(getMember,Foo.init, mem)) { enum prot = __traits(getProtection, __traits(getMember, Foo.init, mem)); // and so on } } I haven't

Re: Traits: getting all *public* members of a class?

2013-06-08 Thread Andrej Mitrovic
On Saturday, 8 June 2013 at 13:57:13 UTC, Q wrote: Hi there, I want to iterate over all the public members of a class. It is a known problem. The workaround is to use is(typeof()): void main() { foreach (mem; __traits(allMembers, Foo)) { static if (is(typeof( __trai

Traits: getting all *public* members of a class?

2013-06-08 Thread Q
Hi there, I want to iterate over all the public members of a class, but I've hit a stumbling block when the class resides in a different module and also contains private members. For example: $ cat foo.d class Foo { private int x; public int y; } $ cat main.d import foo; void main() {

Re: dispatch table; symbolic references

2013-06-08 Thread bearophile
Emil: This works, but I am wondering if there is another way. Does D support symbolic references so I could keep the hashtable in a string[string], or even use a string variable holding a class name to instantiate a class ? There is a create, but I think it's still very limited and I think

dispatch table; symbolic references

2013-06-08 Thread Emil
need a dispatch table and tried it this way: class Action { string[string] function(string[string] p) action; this( string[string] function(string[string] p) action_ref ) { this.action = action_ref; } string[string] execute(string[string] parameters) { return this.