[C++-sig] generic object wrappers

David Abrahams david.abrahams at rcn.com
Tue Jan 22 20:56:28 CET 2002


----- Original Message -----
From: "Arnaldur Gylfason" <arnaldur at decode.is>
>
> I believe many of the abstractions in operators are clear to those used to
> mathematical
> language, esp. abstract algebra. For those object<ring> would be clear and
> might be considered superior to object<addable,subtractable,multipliable>.
> Those who find it unclear could happily ignore these combinations.

...or learn them ;-)

> This is
> not important though.

Agreed.

> Yeah I meant to add that maybe you needed it in other parts of
> boost.python.
> Sadly, I must admit I have not taken a look at other parts and can't
> comment on
> them at this stage.
> All in all I believe this design is good and 1 case where it will benefit
> you (or me)
> is enough to warrant it.
>
> Regarding typecasts, yes they're ugly. Inside a concrete object wrapper
> like list it should
> be safe though. Using a reinterpret_cast makes the typecasts obvious in
> code.

Technically speaking, you shouldn't use reinterpret_cast<> in portable code.
It's behavior is implementation-defined (5.2.10). A C-style cast is actually
portable and safer.

> After downcasting to a PyListObject* I could build a
> reference<PyListObject*> and benefit
> from automatic conversions after that yes, but the usage I had in mind was
> just touch and go,
> i.e. there wasn't really any need of keeping a PyListObject*, I just
needed
> the typecast
> to access an attribute for the PyListObject instance (obitem).
> I think most uses of these typecasts/conversions in the object interface
> part are similar to that.
>
> Don't get me wrong though. It is quite possible I will find out that this
> design comes in handy
> later.

Okay, well, I might do it if you don't.

Regards,
Dave






More information about the Cplusplus-sig mailing list