struct vs class

Lutger Blijdestijn lutger.blijdestijn at
Sun Nov 14 06:40:36 PST 2010

spir wrote:

> On Sun, 14 Nov 2010 12:02:35 +0000
> div0 <div0 at> wrote:
>> > Both of these points may conflict with semantic considerations above:
>>  > we may want to use structs for fast creation, but if ever they mean
>>  > "things", we must think at referencing them manually and/or using
>>  > ref parameters. We may want to use classes for light passing,
>>  > but if they mean values, we must either never assign them or
>>  > manually copy their content. It's playing with fire: very
>>  > dangerous risks of semantic breaks in both cases...
>> Perhaps, but they are tools to implement a program design;
>> it's the program design that should be driving your choices not abstract
>> semantic considerations. Go down that route and you'll never get
>> anything done.
> I do not really get what you mean with "program design" as opposed to
> "semantic considerations". I tend to think that "program design" should
> precisely be driven by "semantic considerations" -- and that it's the main
> purpose of good language design to allow this as straightforwardly as
> possible. A bad langage is for me one in which one can hardly express what
> is meant -- leading to what I call "semantic distorsion" ;-). So, what is
> "program design" for you?
> Denis
> -- -- -- -- -- -- --
> vit esse estrany ☣

If I may add my 2 cents: program design is where, in another response, you 
choose to pass a cursor into a source text by reference and have methods 
update that reference directly instead of returning a new cursor. You have 
chosen a class, but a pointer inside a struct it could be done as well.  

More information about the Digitalmars-d-learn mailing list