Aggregates & associations

Bruce Adams tortoise_74 at yeah.who.co.uk
Thu Dec 20 17:23:56 PST 2007


On Thu, 20 Dec 2007 14:38:40 -0000, Jarrett Billingsley  
<kb3ctd2 at yahoo.com> wrote:

> "Bruce Adams" <tortoise_74 at yeah.who.co.uk> wrote in message
> news:op.t3mssesyxikks4 at lionheart.cybernetics...
>
>> Sorry I should have qualified that. Scope as I understand it, declares
>> whether
>> a variable should be deleted or it. i.e. whether it is owned by the
>> current scope,
>> which in the proposed extension would mean class scope. It does not say
>> anything
>> about the memory layout. Whether the object is a value or reference is
>> still up
>> for grabs. It doesn't usually matter in functions but in a class it  
>> does,
>> at least
>> as an optimisation.
>
> See, it's an optimization.  Guess who should be doing optimizations?   
> Hint:
> it's not the programmer.  I'd place manual specification of whether a  
> scope
> class is allocated inline the body of its owning class or function in the
> same category as "inline" and "register" -- ultimately meaningless hints  
> to
> the compiler to do something that it can figure out better than you can.
> Chances are if we got scope class references in classes they _would_ be
> inlined into the owning class's body, if for no other reason than the
> principle of least surprise -- it already happens in functions -- and  
> also
> because, well, it's a good optimization.
>
> This is why C++ is complex.  It gives you all these possibilities and
> features, but leaves it up to you to make something useful out of them.   
> D
> tries to give you useful _semantic_ features whose semantics leave room  
> for
> optimization, freeing you from dealing with the low-level crap that C++
> makes you deal with.  I don't want D to go to the way C++ does it.
>
Its not quite as simple as that. What needs to be optimised depends on how  
the program is
used. The compiler cannot know that unless you add some pretty strong AI  
(or
at least a way to feedback profiling results to your compiler). This is why
inlining is still occasionally useful in C++, not because of bad language  
design.



More information about the Digitalmars-d mailing list