Re: Immutable member functions on mutable objects

2009-12-01 Thread Steven Schveighoffer
On Sun, 29 Nov 2009 07:23:07 -0500, Tomek Sowiñski 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: function he

Re: Immutable member functions on mutable objects

2009-11-30 Thread BCS
Hello Tomek, 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 () immutable

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 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 does not co

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 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()

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 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: function he

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; // O

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; } } vo

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