On Mon, Apr 4, 2022 at 7:55 PM Henry Rich <[email protected]> wrote:
> Accessing the symbol table is deprecated. Don't do it.

That sounds like solid advice.

And, I am going to quote your final advice, up front, to avoid too
much distraction from my upcoming question:

> WHAT YOU NEED TO DO is use 15!:14 if you want the address of the first
> atom, or 15!:12 (new in J9.04) to get the address of the header.  The
> header and data will not be relocated.

There's some behind the scenes concepts here that are probably worth
understanding. But, for most purposes, this much is probably
sufficient.

That said...

> The J symbol table is a contiguous array of structures that connect
> names and values.  When the table fills, a larger one is allocated and
> the symbols are all relocated.  The table may become full any time a new
> symbol is created.
>
> Thus, your very first line
>
> s=. symget <y
>
> is not robust.  symget will return a pointer (as an integer), but the
> assignment to s may relocate the symbol table, which means that your
> pointer may be invalid before you even store it into s.
>
> There is no way around this, and the problem applies to all releases of JE.

Is that really an issue here? In other words, would allocating a local
symbol update the global symbol table?

(If it was, it seems like pre-allocating all symbols that your routine
would use before referencing the symbol table would work around that
issue.)

> If that's not bad enough, a routine you call, or a J task running in a
> thread, may delete any global name and leave you with an invalid pointer.

Definitely a risk. One that would have to be managed.

> WHAT YOU NEED TO DO is use 15!:14 if you want the address of the first
> atom, or 15!:12 (new in J9.04) to get the address of the header.  The
> header and data will not be relocated.

Thanks,


--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to