Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you specify the 8th namespaces in an array?

Tags:

forth

8th

8th uses namespaces instead of vocabularies. Each namespace has its own integer representation.

ok> ns:a . cr ns:n . cr
4
2

So, 2 is for the number namespace, and 4 is for arrays.

I want to construct an array holding the namespaces which I can then place at the TOS (top of stack).

However, if I just write this

ok> [ ns:a , ns:n ]
Exception: invalid JSON array: at line 1 char 3 in ....: cr (G:;;; +000004c2)
Exception: can't find: :a: at line 1 char 6 in (null): cr (G:??? +00000029)
Exception: can't find: ,: at line 1 char 8 in (null): cr (G:??? +00000029)
Exception: can't find: ]: at line 1 char 15 in (null): n (G:??? +00000029)
like image 336
Graham Chiu Avatar asked Nov 07 '25 18:11

Graham Chiu


1 Answers

I'm the developer of 8th. The solution with ' ns:a is not really what you want, since that puts the word in the array instead of the value that word would return.

You can accomplish what you're looking for by using the backtick: [ ` ns:a ` ]

The backtick feeds the text up to the next backtick to eval and puts the value (whatever it is) in the JSON you're creating (it's not limited to JSON, it's a general construct).

like image 193
8th_dev Avatar answered Nov 12 '25 16:11

8th_dev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!