texmacs-dev
[Top][All Lists]
Advanced

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

Re: [Texmacs-dev] How to mark/copy objects in C++


From: Joris van der Hoeven
Subject: Re: [Texmacs-dev] How to mark/copy objects in C++
Date: Tue, 25 May 2004 10:10:55 +0200 (CEST)

On 24 May 2004, Gabriel Dos Reis wrote:
> Joris van der Hoeven <address@hidden> writes:
> | A question for Gabriel: would there be an easy way to implement
> | type-safe marking/copying routines in C++ for all TeXmacs types.
> | Of course, we can manually write such routines for each type,
> | but there might be a more automatic way. What do you think?
>
> One more tip.  If you have a polymophic type T, and a pointer "p" of
> type *T -- that may actually points to a complete object of type U
> derived from T, then
>
>      dynamic_cast<void*>(p)
>
> gives you a pointer to the start of the storage of the complete
> object.  Therefore, you would be able to mark the complete object and
> you would need to implement the specific bits of marking/copying only
> for the "leaves classes" or "sealed classes", i.e. those from which
> you no longer derive from.  That gives you something very general.

OK. But that does not yet answer my main question: how to automatically
and reliably traverse all pointers of data structures. It is a pity that
C++ does not provide any support for this (in a similar way as operators
new and delete, one might have an operator mark with a default
implementation; that would hugely easy writing garbarge collectors).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]