How do I find the arity of an Expression? (dmd hacking)

2009-11-29 Thread Chad J
Given an Expression object in dmd, I'd like to know how many subexpressions it contains and, even better, iterate over them. I'd like to do this in a general way, without having to create cases for all of the different kinds of Expressions. Is there some way to do this that I've been missing?

Re: Reference counting for resource management

2009-11-29 Thread LMB
Don Wrote: LMB wrote: [...] So, is there any complete example on how to implement reference counting in D2? I don't think so. While trying to do it, Bartosz found some severe bugs in D which made it impossible; they were fixed in the last release. He's since found bug 3516 might

Immutable member functions on mutable objects

2009-11-29 Thread Tomek Sowiñski
I've got a problem calling an immutable getter on an ordinary object. struct A { float _pole; float pole() immutable { return _pole; } } void main() { A a; auto x = a.pole; // Ouch! } Error: function hello.A.pole () immutable is not callable using argument types

Re: Immutable member functions on mutable objects

2009-11-29 Thread Tomek Sowiñski
Tomek Sowiñski Wrote: I've got a problem calling an immutable getter on an ordinary object. [snip] Weird: if I reverse the situation -- the object is immutable and function is ordinary -- I also get an error. struct A { float _pole; float pole() { return _pole; } } void

Re: Immutable member functions on mutable objects

2009-11-29 Thread Tomek Sowiñski
Tomek Sowiñski Wrote: Weird: if I reverse the situation -- the object is immutable and function is ordinary -- I also get an error. struct A { float _pole; float pole() { return _pole; } } void main() { immutable A a; auto x = a.pole; // Ouch! }

Re: Immutable member functions on mutable objects

2009-11-29 Thread Simen kjaeraas
On Sun, 29 Nov 2009 13:23:07 +0100, Tomek Sowiñski j...@ask.me wrote: I've got a problem calling an immutable getter on an ordinary object. struct A { float _pole; float pole() immutable { return _pole; } } void main() { A a; auto x = a.pole; // Ouch! } Error:

Re: Detect runtime vs ctfe?

2009-11-29 Thread Lars T. Kyllingstad
Nick Sabalausky wrote: Is there an idiom, preferably D1, to detect whether or not the code is currently executing as a ctfe? Ie: void foo() { (static?) if( ) { // Run-time code here // that does stuff the CTFE engine chokes on } else { // CTFE

Re: Immutable member functions on mutable objects

2009-11-29 Thread Tomek Sowiñski
Simen kjaeraas Wrote: On Sun, 29 Nov 2009 13:23:07 +0100, Tomek Sowiñski j...@ask.me wrote: I've got a problem calling an immutable getter on an ordinary object. struct A { float _pole; float pole() immutable { return _pole; } } void main() { A a;

Re: Immutable member functions on mutable objects

2009-11-29 Thread Simen kjaeraas
On Sun, 29 Nov 2009 19:15:19 +0100, Tomek Sowiñski j...@ask.me wrote: A is not implicitly castable to immutable(A), only to const(A). I think it is. This compiles: immutable a = A(3.4); But only because it's copied. Not quite. If you try immutable(A) a; a = A(3.4); you should find that it

Re: Potential memory leak?

2009-11-29 Thread Eldar Insafutdinov
Qian Xu Wrote: Hi All, I am using QtD to do some gui stuff. As the QtD documentation described, Qt- data types should be declared with keyword scope, so that all variables can be deallocated in a right order. I found a memory leak problem accidentally, when I executed the following