On Thu, 12 Aug 2010 22:09:51 -0400, Michel Fortin
<michel.for...@michelf.com> wrote:
On 2010-08-12 18:56:50 -0400, dsimcha <dsim...@yahoo.com> said:
How can these limitations be worked around and/or fixed?
Unsatisfaction about Rebindable seems pretty generalized.
Here's an idea for a solution. Basically the problem is only in the
syntax, where the reference is implicitly part of the object's type and
thus impossible to put outside from the type modifier. An easy solution
would be to add an explicit reference marker, but this would change the
syntax for existing code, and I have to admit the current syntax is nice
(up until you try to add a modifier). But we could make the reference
marker optional, like this:
Object o; // implicitly a reference
Object ref o; // explicit reference marker
Both would be allowed and equivalent. While the first form is nicer to
the eye, the second makes it easy to apply a type modifier while
excluding the reference:
const(Object)ref o;
shared(Object)ref o;
I really really like this idea. I remember seeing a suggestion like this
a long time ago, but I think it was ref const(Object). That is ambiguous
because you could have a ref to an object ref. With your idea, I think
this would be ref const(Object) ref (a little ugly, but no worse than
const const(Object) fn()).
I like how it reads naturally. I think it's also syntactically
unambiguous. Walter, please give this one some attention, I'd love to see
this fixed.
-Steve