On Mon, Apr 8, 2024 at 8:14 AM Jean Louis Faucher <jfaucher...@gmail.com>
wrote:

> RexxMemory.cpp
>     IntegerZero   = new_integer(0);
>     IntegerOne    = new_integer(1);
>     ...
>
> Looking at RexxMemory::live, I don’t see what is marking IntegerZero.
>

This is a good question, and the answer is not particularly obvious! It
took me a little while to figure this out. The assignment

   IntegerZero = new_integer(0);

Returns an instance from the integer cache maintained by the
RexxIntegerClass object. These are all marked by the live() method on the
object, so RexxMemory doesn't need to do anything special.


>
> Other global static variables like TheTrueObject  or nullPointer are put
> in a collection.
>     addToEnvironment("TRUE", TheTrueObject);
>     addToSystem("NULLPOINTER", TheNullPointer);
> and protected:
>     memory_mark(environment);
>     memory_mark(system);
>
>
> Side question, out of curiosity:
>     // Create some special Rexx objects.
>     TheTrueObject  = new RexxInteger(1);
>     TheFalseObject = new RexxInteger(0);
> With these assignments, we have TheTrueObject <> IntegerOne, right?
> Why not assigning IntegerZero, IntegerOne?
>

Six of one, half dozen of another. It could easily be done that way. Not
sure there's any real benefit in doing so. What might be better would be to
remove the static variables from IntegerClass and change the defines to
directly address the cache entries in RexxIntegerClass.

Rick


> _______________________________________________
> Oorexx-devel mailing list
> Oorexx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to