don't understand "if ~ defined x / restore x / define x"
Tomasz, in your new instruction set macros, I saw
if ~ definedx
but I don't seem to understand how it works.
`if ~ defined x` checks whether a symbol is NOT defined anywhere in code (either backwards or forward referenced)
then `restore x` is to undefine x. But why restore if it is not yet defined?
As I see it, it should be
Joined: 16 Jun 2003
Location: Kraków, Poland
Re: don't understand "if ~ defined x / restore x / define x"
`if ~ defined x` checks whether a symbol is NOT defined anywhere in code (either backwards or forward referenced
This is a crucial part. If a symbol is a variable symbol and cannot be forward referenced, it can only be detected through backward referencing, that is when it is defined earlier in the source.
RESTORE is a "nop" when a symbol has not yet been assigned any value, but "touching" a symbol with RESTORE forces it to become a variable symbol, ensuring that it cannot be forward-referenced. So you should interpret that "restore x" line as meaning "treat x as a variable (and disallow forward-referencing it)".
To make this snippet clearer you could make a macro with a name suggesting the purpose of this construction:
if ~ definedx
The DEFINE is in the macro to ensure that it does not accidentally destroy any previous value of a symbol. This is similar to the macro I used in my text about namespace separation.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum