E
Erik Wikström
Ha! C++ is complexity incarnate! Pushing stuff into the compiler is
not reducing complexity, it's just moving it elsewhere.
First of all I do not agree that the complexity for the compiler is
increased by any significan amount (after all, every abstraction that
takes you away from assembly-language is added complexity) but
constructors and such are relatively simple.
Probably because you were more interested in "objects" being in
contiguous memory and performance. That's why I said built-in arrays
are different from "containers". Sure you can slap an interface on
anything, but the implementation issues are what this thread is
about, rather than just abstractions.
No, I was interested in storing a variable number of values and
accessing them in various ways. Sure, I could have used arrays instead
but then I would have to do all the book-keeping myself. By using pre-
existing containers I reduced the complexity of my code significantly,
and probably got better performance too.
The one who said "it means you need two sets of code" above someone
with the paradigm that containers are value-based things, probably
because of some kind of derivation of what a container is based upon
built-in arrays, which leads to "hence, class objects need to behave
like built-in types to be used by value-based containers", was why I
posed the "how many linked lists of integers..." question and
"theory" that value-based containers aren't even desireable mostly.
I will not speculate about his reasoning but I can say this: The fact
that the container can also handle class-types have been useful in some
situations (for example I can switch to debugging by just changing a
#define/typedef).
No what?
No, using linked list would not be a better example.
I would hope not.
Built in arrays are different beasts. It would probably not be
prudent to make the "raw materials of composition" (built-ins), class
objects. One can wrap those for more specific purposes.
Not sure what you mean here.
My original
question is still open. Maybe there are 2 (or more) types of classes:
those that behave like built-ins and those that are something else.
That "something else" being lightweight and not nearly as complex as
requiring compiler-called constructors and then exceptions to solve
the "problem" with constructors.
In my experience its the classes that do not behave as built-in types
that are the more complex ones (singletons, non-value semantics, etc.).
That's not topical though, and is paradigmical and a very
high-level/abstract "definition" (and even moreso, a definition of
"container interface" rather than "container").
No, definitely not a definition of a container interface. It's a
definition of a container in terms of an interface, i.e. the interface
specifies what a container is and everything that implements the
interface is a container.
Containers were brought into the discussion when someone said that
built-in-type-behavior of class objects is required so that
containers can be implemented, which of course is wrong in the
general sense.
Of course, but he only said that it is necessary to implement practical
and useful containers. As pointed out there are other ways of doing it,
such as using boxing and typecasting (generics can hide some of this
from the user but that is all).