3 ms·
this is a great idea, among other things because it puts the name you're defining in the left margin where it's easiest to scan to, but i don't see how it avoid
by kragen 4y ago
this is a great idea, among other things because it puts the name you're defining in the left margin where it's easiest to scan to, but i don't see how it avoids any compile-mode nonsense. in this line of code, 'cube still has to push the string on the stack at compile time, and : has to consume it at compile time, while dup just has to compile some code into the colon definition, which at least strongly suggests that the interpreter is being run in a different mode that compiles things like dup instead of executing them?
https://stoical.sourceforge.net/summary.php https://stoical.sourceforge.net/summary.php
https://sourceforge.net/projects/stoical/files/stoical/0.1.8/ https://sourceforge.net/projects/stoical/files/stoical/0.1.8...
some example code
% %(var) 1+!
% Increment the variable addressed by TOS.
% %
'1+! : dup @ 1+ swap ! ;
% %(math) hex
% Set radix to hexadecimal.
% %
'hex : 16 radix ! ;
% %(io) cr
% Output a newline.
% %
'cr : '\n = ;
% %(io) space
% Output a space.
% %
'space : 32 put ;
% ----- define the more traditional interface to flow control.
% %(conditional) if (*)
% "n IF ... then"
% Conditionaly execute the instructions. The instructions following IF will be
% executed if TOS is not FALSE upon invokation.
% %
'if : () if{ exec ; immediate
it seems to be dynamically-typed and garbage-collected?