The Status of Const

Michel Fortin michel.fortin at michelf.com
Thu Aug 12 19:09:51 PDT 2010


On 2010-08-12 18:56:50 -0400, dsimcha <dsimcha at 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;

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list