On 2010-12-06 14:46:51 -0500, spir <[email protected]> said:
On Mon, 6 Dec 2010 13:44:41 -0500
Michel Fortin <[email protected]> wrote:
Since we're speaking of the optional use of 'ref', here's a little quiz:
alias Object A;
alias Object ref B;
A ref a;
B ref b;
What happens here? Should there be an error somewhere? Where? Also,
what happens if we apply different modifiers at different places?
As I understand the (non-)semantics of 'ref', there should be no error. Thi
s code should considered by the compiler as equivalent to:
Object a;
Object b;
And that's what my patch does. It only gets confusing when you add modifiers:
alias const(Object)ref A;
alias const(Object ref) B;
alias const(Object) C;
A ref a;
B ref b;
C ref c;
With my patch, variables 'a', 'b', and 'c' are all of the same type:
"const(Object)ref", the later 'ref' changing the constness of the
reference specified in the 'B' alias.
Note that while this behaviour is allowed with an alias, it is *not*
allowed directly, so you can't write this for instance:
const(Object ref) ref d;
That's an error.
--
Michel Fortin
[email protected]
http://michelf.com/