What is the difference between...

Janice Caron caron at serenityfirefly.com
Fri Sep 7 05:22:13 PDT 2007


-----Original Message-----
From: digitalmars-d-bounces at puremagic.com 
[mailto:digitalmars-d-bounces at puremagic.com] On Behalf Of Daniel Keep
Sent: 07 September 2007 12:58
To: digitalmars-d at puremagic.com
Subject: Re: What is the difference between...

> const(T) only has an effect on reference types.

O-Kaaaay.

Forgive me, but, that seems arbitrary and ... silly. If const(T) worked on all 
types, we'd have no need for const T, surely?

So, let's see if I've understood this right. Given

 struct S { int x; } /* a non-reference type */
 class C { int x; } /* a reference type */

 void f(const(S) s, const(C) c)
 {
     s.x = 5; /* allowed */
     c.x = 5; /* not allowed */
 }

Is that really, really right? It's going to take me a long time before that 
seems intuitive!




More information about the Digitalmars-d mailing list