-
-
Save crcx/255190 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: :create ( $- ) | |
push :: save string pointer | |
here last dup @ , ! :: start new header, pointing to here | |
['] .data , :: class of .data | |
here 0 , :: xt = 0 (patched later) | |
pop dup getLength here :: get length of string, setup for copy | |
swap dup allot :: but first, allocate space for the name | |
copy 0 , :: copy name to allocated space, terminate string properly | |
here swap ! ; :: go back and patch the xt to point to here | |
: t s" test" :create ; | |
t words |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: append ( $$-$ ) | |
swap | |
here push | |
here over getLength dup allot copy | |
here over getLength dup allot copy | |
0 , pop ; | |
: prepend ( $$-$ ) swap append ; | |
: paren-wrap ( $-$ ) s" (" prepend s" )" append ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment