diff --git a/example/hiding-words.retro b/example/hiding-words.retro new file mode 100644 index 0000000..134d6cf --- /dev/null +++ b/example/hiding-words.retro @@ -0,0 +1,39 @@ +# Hiding Words + +It's often useful to be able to hide a word from the global +dictionary. This can be done with the lexical scope words, +but here I present a different approach. + +To hide a word, it is sufficient to change its name to +something that will never be matched. Since strings are +null terminated, just replacing the first character with +a null suffices. + +So all that needs to be done is to create an array of headers +we want to hide, then iterate over that to smudge out the +names. + +# Code + +~~~ +'To-Hide d:create #65 allot + +:private @Dictionary @To-Hide &To-Hide + n:inc store &To-Hide v:inc ; + +:hide-private + &To-Hide [ d:name v:off ] a:for-each &To-Hide v:off ; +~~~ + +# Example + +``` +:a ; +:b ; private +:f ; private +:c ; +:d ; private +:e ; + +hide-private +``` + diff --git a/vm/nga-c-native-x86/image.c b/vm/nga-c-native-x86/image.c index 0a619ed..d68070b 100644 --- a/vm/nga-c-native-x86/image.c +++ b/vm/nga-c-native-x86/image.c @@ -1,6 +1,14 @@ #include #ifndef CELL +#ifndef BIT64 #define CELL int32_t +#define CELL_MIN INT_MIN + 1 +#define CELL_MAX INT_MAX - 1 +#else +#define CELL int64_t +#define CELL_MIN LLONG_MIN + 1 +#define CELL_MAX LLONG_MAX - 1 +#endif #endif CELL ngaImageCells = 10220; CELL ngaImage[] = { 1793,-1,10207,10219,202104,0,10,1,10,2,10,3,10,4,10,5,10,6,10,