What I am trying to do is understand the lispy idioms for doing certain
things. In this case I'm trying to determine if there is a more lispy
way of assigning field values from one object to another, other than
member wise assignment. In C++, the default for two objects of the same
class when one is assigned to another is a memberwise copy (which is
bad for pointer members). You can create copy contructors and overload
the assignment operator to get the right behavior.
(The above is just example so no comments on the viability of C++)
ie. I've got an Auto class with some basic automobile functionality. I
have a Pickup sub-class of Auto. I've been doing some operations on an
Auto object and I want to use the Auto object to initialize a Pickup
object. (Might not be an initialization but could be an assignment or
something) The obvious way is just to have a method that does a member
wise assignment of fields.
The question is, is that the idiomatic way of doing this or is there a
Another question that occured to me is, Is there the equivalent of a
cast, in this case from pickup to auto and back?
C++ equivalent of:
hAuto &auto = dynamic_cast<Auto&>(pickup);