Re: comparing pointers passed to and returned from funcs

2011-03-02 Thread Steven Schveighoffer
On Tue, 01 Mar 2011 18:11:00 -0500, bearophile bearophileh...@lycos.com wrote: http://d.puremagic.com/issues/show_bug.cgi?id=5678 I think there is a general bug where any time the compiler uses an enum, it simply replaces the expression declared for the enum. So basically enum TRUE =

Re: comparing pointers passed to and returned from funcs

2011-03-02 Thread spir
On 03/02/2011 02:24 PM, Steven Schveighoffer wrote: On Tue, 01 Mar 2011 18:11:00 -0500, bearophile bearophileh...@lycos.com wrote: http://d.puremagic.com/issues/show_bug.cgi?id=5678 I think there is a general bug where any time the compiler uses an enum, it simply replaces the expression

comparing pointers passed to and returned from funcs

2011-03-01 Thread spir
Hello, It seems to be the kind of stupid issue that will make you laugh about me. But I cannot grasp and want to move forward anyway; so, let us be bold and take the risk ;-) I'm modeling a little dynamic language. Elements (values, objects) are pointers to structs (actually tagged unions)

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread bearophile
spir: It seems to be the kind of stupid issue that will make you laugh about me. But I cannot grasp and want to move forward anyway; so, let us be bold and take the risk ;-) Be bold. Understanding things is much more important. I've being wrong hundreds of times on D newsgroups, but

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread bearophile
This seems to work: import core.stdc.stdio: printf; struct Foo { bool b; this(bool b_) { this.b = b_; } } const(Foo)* TRUE, FALSE; static this() { TRUE = new const(Foo)(true); FALSE = new const(Foo)(false); } const(Foo)* not(const(Foo)* op) { return (op == TRUE) ? FALSE :

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread Bekenn
On 3/1/11 3:00 PM, bearophile wrote: const(Foo)* TRUE, FALSE; I'd remove those parens; you don't want people modifying TRUE or FALSE.

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread bearophile
Bekenn: I'd remove those parens; you don't want people modifying TRUE or FALSE. Please, show me working code that implements your idea :-) Bye, bearophile

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread Bekenn
On 3/1/11 4:12 PM, bearophile wrote: Bekenn: I'd remove those parens; you don't want people modifying TRUE or FALSE. Please, show me working code that implements your idea :-) Touche. I'll have to test that out once I get back from work...

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread Bekenn
On 3/1/11 5:31 PM, bearophile wrote: Bekenn: Touche. I'll have to test that out once I get back from work... Sorry for that answer of mine, we are here to learn and cooperate, not to fight :-) It's just I sometimes have problems with const things in D, and sometimes DMD has problems with

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread Bekenn
On 3/1/2011 4:12 PM, bearophile wrote: Bekenn: I'd remove those parens; you don't want people modifying TRUE or FALSE. Please, show me working code that implements your idea :-) Bye, bearophile Here you go; I only changed the one line. Compiles and works just fine in dmd 2.051.