On 2010-12-02 16:14:58 -0500, "Steven Schveighoffer"
<[email protected]> said:
On Thu, 02 Dec 2010 07:09:27 -0500, Michel Fortin
<[email protected]> wrote:
My only concern with the "const(Object)ref" syntax is that we're
reusing 'ref' to denote an object reference with different properties
(rebindable, nullable) than what 'ref' currently stands for. But it
remains the best syntax I've seen so far.
Where it would be beneficial is in mimicking the tail-const properties
of arrays in generic ranges.
I have a container C, which defines a range over its elements R.
const(R) is not a usable range, because popFront cannot be const. So
now I need to define constR, which is identical to R, except the
front() function returns a const element.
So now, I need the same for immutable.
And now I need to triplicate all my functions which accept the ranges,
or return them.
And I can't use inout(R) as a return value for ranges.
If you can solve the general problem, and not just the class
tail-const, it would be hugely beneficial.
My thought was that a modifier on const itself could be stored in the
TypeInfo_Const as a boolean (tail or not), and the equivalent done in
dmd source itself.
I'm not sure I get the problem. Can you show me in code?
--
Michel Fortin
[email protected]
http://michelf.com/