[gclist] C++ proposal

Stefan Monnier stefan.monnier@lia.di.epfl.ch
Wed, 29 May 1996 09:44:33 +0200


> A special and difficult issue is how to handle a union with a pointer
> and a non-pointer member. Consider:

I always thought that the 'definition' of "union" makes it semantically
equal to "struct". It's only the intended meaning which differs. In other
words, "union" is only a hint to the compiler that only one of the entries
inside the union will be used at a time.
This view makes the interaction between "union" and GC non-problematic
(from a 'definition' standmpoint).

> Consequently, I propose (2), leave the mechanism for requesting constructors
> to be called by the collector (``finalizable objects'') unspecified,
> and to introduce a macro to help programmers isolate declarations and/or
> code relating to finalization actions beyond the scope of the standard.
> 
> __COLLECTING
> 
> It should be implementation defined whether an implementation provides
> a garbage collector or not. Should the programmer be able to tell
> whether an implementation collectes or not without doing experiments
> with disguised pointers or timers?

These two problems (registering for finalization and getting info about
the presence of GC) should really be solved by a standard C++ object
(the GC object). This object would understand methods such as "register
object X for finalization", "turn GC on/off", "is GC available" as well
as "don't hesitate to GC X micro-seconds now".

The presence or absence of GC might very well not be known at compile-time,
which makes the use of a macro questionable.

So, how about a GC object (maybe in the standard library) ?


	Stefan