From ccc5e9514111ecec8c045a9b78cb2052da090c95 Mon Sep 17 00:00:00 2001 From: kitty Date: Mon, 23 Mar 2026 00:42:21 +1100 Subject: boilerplate for create does> --- sanctuary.fs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sanctuary.fs') diff --git a/sanctuary.fs b/sanctuary.fs index 4fe9f8c..b0867d1 100644 --- a/sanctuary.fs +++ b/sanctuary.fs @@ -14,11 +14,25 @@ : begin mark ; immediate ( I: -- a ) +: if ?branch >mark ; immediate : else branch >mark swap >resolve ; immediate : then >resolve ; immediate : while ?branch >mark ; immediate : repeat branch swap resolve ; immediate +: ?dup dup 0<> if dup then ; + : allot here swap dp +! ; + +: ?find ?dup if find 0= if 2drop abort then else abort then ; +: 'h parse-name ?find ; +: ' 'h >body ; +: [compile] ' ( word ) compile, ; immediate +: ['] ' ( word ) [compile] literal ; immediate +: postpone 'h ( word ) dup immediate? if >body compile, + else >body [compile] literal ['] compile, compile, then ; immediate + +\ my plan is that (CREATE) is followed by a dummy zero cell +\ which (DOES>) uses. waste of 8 bytes but it's simpler +: create parse-name (header) latest ! ['] (create) compile, 0 , ; bye -- cgit v1.2.3