Boost logo

Boost :

From: Geurt Vos (G.Vos_at_[hidden])
Date: 2002-02-19 04:13:48


> On Mon, 2002-02-18 at 09:04, Geurt Vos wrote:
> > My usual answer to this is: So?
> > How many properties will a class have? I'd say if there were
> > more than a few, you're doing something wrong, but lets make
> > it 7 as maximum 'acceptable' number of properties. On all
> > platform I tested the implementation on, a pointer-to-object
> > has a size of 4 bytes. 7 * 4 = 28 bytes per class. You'll need
> > a whole lot of such objects for it to make a difference. True,
> > seven is not worst case, but it's definitely a bad case...
>
> How about the example you used of a coordinate type? If you used it in
> a vector graphics library it would almost double the memory used.
>

It's true what you say, but it doesn't mean a thing!
I mean, just saying it uses more or less memory, or it's
faster or slower simply doesn't provide any argument why
you should choose one or another approach. Saying it's
too slow because 1)..., 2)... and 3)... or it uses too
much memory because ..., now that might (!) make you
think about the approach chosen (or which one to choose).

...but it is exactly what I was afraid of: it won't
be accepted by the sheer fact that it uses more memory
and object creation is slower...

> Is there a reason that a function returning a proxy will not do the job?
> It avoids the storage problem and does not need the user to change their
> constructors when they add a property.
>
> The only penalty is that you have to put brackets after the property
> name when you use it. As far as I can tell what you already have would
> not need a lot of modification to work as proxy.
>
> See my previous post
> http://groups.yahoo.com/group/boost/message/25317
>

Ah, must have missed this one. Interesting approach,
I'll try it...

> a) Use multiple inheritance
>
> class value {};
>
> class A : public
> property_owner< A, int, value, &A::get_value, &A::set_value >,
> property_lookup< A >
> {
> public:
> } x;

This won't work. get_value and set_value aren't
known at this point.

> b) Use a macro. Yuk but it might be the simplest solution.

You could, but I won't...

> > Secondly, you're talking about VC6, running on Windows, right?
> > Machines on Windows (or actually, machines on anything) are
> > loaded with memory. Well, at least in such a way that it
> > doesn't matter whether an application uses 1Mb or 10Mb of
> > memory. If it does, I suggest buying some memory because
> > there's far worse out there than properties.
>
> Yeah but my Zaurus only has 24MB RAM and a lot of that is used up once I
> run samba and openssh :-)
> http://www.sharp.co.uk/pda/pda.htm
>

Linux + Java...and you're complaining every property
takes a few bytes of memory? :)

Geurt


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk