digitalmars.D - Const question
- Graham St Jack (8/8) Mar 23 2008 I have finally taken the plunge and moved over to D 2.x.
- Craig Black (4/8) Mar 23 2008 This is still being discussed? Is Walter considering a fix for it?
- Graham St Jack (3/14) Mar 23 2008 The discussion is under "const debacle", posted on 19th March. It looks
- Walter Bright (2/4) Mar 23 2008 The const debacle thing is something else.
- Graham St Jack (5/10) Mar 24 2008 Oops.
- Walter Bright (3/6) Mar 27 2008 There is no plan to have a mutable reference to const class contents. It...
- Graham St Jack (2/9) Mar 31 2008 Ok, I can live with that. Thanks for the clarification.
- Janice Caron (7/8) Mar 24 2008 Not Walter, Andrei. Andrei has a template solution, Rebindable!().
- Simen Kjaeraas (7/15) Mar 24 2008 opAdd and friends are easy to fix in most situations:
I have finally taken the plunge and moved over to D 2.x. The experience is good so far except for a few problems with const (I want const btw), the biggest of which is the tail-const issue for classes, which is still an active area of discussion. My question is more mundane - are there plans to fix the const- correctness of things in the language and phobos, specifically things like opCmp, opAdd, etc? I find I am having to cast away const in order to use overloaded operators, which is very annoying.
Mar 23 2008
"Graham St Jack" <grahams acres.com.au> wrote in message news:fs6mtj$1muc$1 digitalmars.com...I have finally taken the plunge and moved over to D 2.x. The experience is good so far except for a few problems with const (I want const btw), the biggest of which is the tail-const issue for classes, which is still an active area of discussion.This is still being discussed? Is Walter considering a fix for it? -Craig
Mar 23 2008
On Sun, 23 Mar 2008 20:46:43 -0500, Craig Black wrote:"Graham St Jack" <grahams acres.com.au> wrote in message news:fs6mtj$1muc$1 digitalmars.com...The discussion is under "const debacle", posted on 19th March. It looks like plenty more thinking is needed to sort it out.I have finally taken the plunge and moved over to D 2.x. The experience is good so far except for a few problems with const (I want const btw), the biggest of which is the tail-const issue for classes, which is still an active area of discussion.This is still being discussed? Is Walter considering a fix for it? -Craig
Mar 23 2008
Graham St Jack wrote:The discussion is under "const debacle", posted on 19th March. It looks like plenty more thinking is needed to sort it out.The const debacle thing is something else.
Mar 23 2008
On Sun, 23 Mar 2008 22:36:08 -0700, Walter Bright wrote:Graham St Jack wrote:Oops. While I have your attention, what is the plan for expressing that an object is const or immutable and to have a mutable reference to it? Arrays are fine (like "string"), but what is the deal for classes?The discussion is under "const debacle", posted on 19th March. It looks like plenty more thinking is needed to sort it out.The const debacle thing is something else.
Mar 24 2008
Graham St Jack wrote:While I have your attention, what is the plan for expressing that an object is const or immutable and to have a mutable reference to it? Arrays are fine (like "string"), but what is the deal for classes?There is no plan to have a mutable reference to const class contents. It just doesn't work in the type system.
Mar 27 2008
On Thu, 27 Mar 2008 23:05:03 -0700, Walter Bright wrote:Graham St Jack wrote:Ok, I can live with that. Thanks for the clarification.While I have your attention, what is the plan for expressing that an object is const or immutable and to have a mutable reference to it? Arrays are fine (like "string"), but what is the deal for classes?There is no plan to have a mutable reference to const class contents. It just doesn't work in the type system.
Mar 31 2008
On 24/03/2008, Craig Black <craigblack2 cox.net> wrote:This is still being discussed? Is Walter considering a fix for it?Not Walter, Andrei. Andrei has a template solution, Rebindable!(). Unfortunately, right now it's undocumented and shouldn't be used because it will likely change as D2 changes. I think Andrei is waiting for D to support opImplicitCast. I think, once we have that, his template will work as you'd expect. This is discussed in the thread "Idea to ease tail-const class reference woes".
Mar 24 2008
On Sun, 23 Mar 2008 23:51:31 +0100, Graham St Jack <grahams acres.com.au> wrote:I have finally taken the plunge and moved over to D 2.x. The experience is good so far except for a few problems with const (I want const btw), the biggest of which is the tail-const issue for classes, which is still an active area of discussion. My question is more mundane - are there plans to fix the const- correctness of things in the language and phobos, specifically things like opCmp, opAdd, etc? I find I am having to cast away const in order to use overloaded operators, which is very annoying.opAdd and friends are easy to fix in most situations: const Foo opAdd(const Foo rhs) Of course, if this pattern is not used in the std lib, that is Walter's (and others') job. -- Simen
Mar 24 2008