Why can't we define re-assignable const reference variable?
Christopher Wright
dhasenan at gmail.com
Sat Feb 16 13:51:48 PST 2008
Janice Caron wrote:
> On 16/02/2008, Christopher Wright <dhasenan at gmail.com> wrote:
>> What's the difference (save polymorphism) between a pointer to a struct
>> and a reference to an object?
>
> I don't understand the question.
>
> What's the difference between chalk and cheese? What are you getting at?
Well, chalk has a significantly higher calcium content and has usually
not gone through a cow.
In C++, there's no difference between the two. In D, the difference
appears to be that there is no syntax separate the reference from the
object, besides an ugly cast.
I've never heard any explanation of how reassignable const objects would
break the type system, and it seems to me that, if they would, then you
shouldn't be able to do:
struct Foo{}
const(Foo)* fptr;
More information about the Digitalmars-d
mailing list