Aggregates & associations
Jarrett Billingsley
kb3ctd2 at yahoo.com
Thu Dec 20 06:38:40 PST 2007
"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.
More information about the Digitalmars-d
mailing list