View mode: basic / threaded / horizontal-split · Log in · Help
December 16, 2009
Re: transporting qualifier from parameter to the return value
Michel Fortin Wrote:

> 	class Test {
> 		void doThat() immutable {}
> 		void doThat() const {}
> 		void doThat() {}
> 		void doThat() shared immutable {}
> 		void doThat() shared const {}
> 		void doThat() shared {}
> 
> 		void doSomething() inout // or vconst
> 		{
> 			doThat(); // which doThat does it call?
> 		}
> 	}

Const function will be called. I replied about sharing in another post.

> 	class Test {
> 		void doThat() immutable {}
> 		void doThat() shared immutable {}
> 
> 		void doSomething() inout // or vconst
> 		{
> 			doThat(); // which doThat does it call?
> 		}
> 	}

It's a compile-time error: vconst is orthogonal to immutable, so you can't pass vconst(this) as immutable(this). Immutable methods are callable only on immutable data. Period.
Top | Discussion index | About this forum | D home