[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (OT) Re: memory management

Pierre Phaneuf <pp@ludusdesign.com> on 07/09/99 15:11:42

Please respond to linuxgames@sunsite.auc.dk

To:   linuxgames@sunsite.auc.dk
cc:    (bcc: Keith Lucas/Restricted/Cumbernauld/Atlantech)

Subject:  Re: (OT) Re: memory management

Keith Lucas wrote:

On a more serious take:

> I've tried it and honestly wouldn't recommend it. For one thing, a base
> object heavyweight enough to support persistence and so on is probably
> overkill for the kinds of lightweight objects you want to be throwing around
> inside the program (bear in mind you're going to want to return things by
> value sometimes).

Personally, here's my base object:

class Object {
  virtual ~Object {};

>Is that lightweight enough for you? Does two things: enables general
>containers by having a type compatible with all the other ones and makes
>destructor works correctly

OK, it's lightweight but it's not actually that useful. You might as well have
the containers use void* pointers for all the benefit you get - the run-time
dynamic casting will still tell you if it's a valid pointer to a
Object:foo:bar:wibble:concrete:myclass or not.

It could at least support creation by string name... but then it starts getting
heavyweight again.

>(damn C++, why isn't "virtual" the friggin' DEFAULT???).

I agree. It should be. Certainly in classes. I could see a point for it not
being in structures - same as they have different visibility defaults.