Value vs. reference semantics, and pointers

Bruno Medeiros daiphoenixNO at SPAMlycos.com
Fri Mar 24 12:31:45 PST 2006


Oskar Linde wrote:
> Bruno Medeiros wrote:
>> That is not correct (and you know it, have you forgotten?).
> 
> I fail to see what's wrong with my statement. Maybe the word "still".
> But you are correct that this needs some clarification.
> 
My mistake, (due to canceling and reposting my message) I quoted the 
wrong part of your post. My post was only meant to reply to this (right 
after you say "That is correct"):

Bruno Medeiros wrote:
 > Oskar Linde wrote:
 >> Scott L. Burson wrote:
 >>> I've been skimming the material on the D Web site and want to be sure I
 >>> understand some things.  I gather that structs and unions have value
 >>> semantics,
 >>> while arrays and classes have reference semantics.  That is,
 >>> assignment to a
 >>> variable of struct or union type copies the contents, while
 >>> assignment to a
 >>> variable of array or class type copies a reference to the contents.
 >>> Is that
 >>> correct?  You might want to clarify this in the docs, as it's pretty
 >>> fundamental.
 >>
 >> That is correct.
 >>

Repost:

That is not correct (and you know it, have you forgotten?).
A static array (and by static array we mean an array of fixed size, as 
C's arrays) is neither a proper value or reference type. It is an odd 
mix of the two, and IMO a bad discrepancy. Perhaps this is something D 
could be improved upon. (don't a formed ideia how, though)
Dynamic arrays (dynamic length arrays) are "a bit more" than a reference 
type, but they behave pretty much as reference type, so one can consider 
them as such.

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list