From 64984f5987264fb06587fb669801f8c6f4fdcc31 Mon Sep 17 00:00:00 2001 From: kitty Date: Mon, 13 Apr 2026 01:10:01 +1000 Subject: un-standardise `abort"` i like it better this way --- readme.md | 9 +++++---- sanctuary.fs | 10 +++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index c2cc91a..1a528c0 100644 --- a/readme.md +++ b/readme.md @@ -58,9 +58,9 @@ have a closing bracket: ). ### `(0handler) ( -- )` the very early error handler, which simply quits the program. -### `(abort") ( ? -- )` +### `(abort") ( a u -- )` perform the runtime actions of `abort"`: -check for non-zero and print and abort, or do nothing. +print string to error and abort. ### `(create) ( -- )` the default behaviour of a word made by `create`, @@ -282,8 +282,8 @@ duplicate the two topmost values on the stack. call the error handler (the address of which is in the variable `handler`) -### `abort" ( ? -- ) IMMEDIATE COMPILE-ONLY` -if `?` is non-zero, write the message that follows (terminated by `"`) +### `abort" ( -- ) IMMEDIATE COMPILE-ONLY` +write the message that follows (terminated by `"`) to standard out then call the error handler. (the address of which is in the variable `handler`) @@ -836,3 +836,4 @@ but it diverges in a few notable places: (128 bit integer arithmetic does not seem all that useful to me) - the dynamic allocation `free` word requires a length. this is because munmap requires a length. +- `abort"` does not take a flag and always executes. diff --git a/sanctuary.fs b/sanctuary.fs index 0922cbc..e555055 100644 --- a/sanctuary.fs +++ b/sanctuary.fs @@ -215,7 +215,7 @@ init-source value source-id : ." postpone s" postpone type ; immediate compile-only \ " : e." postpone s" postpone warn ; immediate compile-only \ " -: (abort") ( ? a u -- ) rot 0<> if warn abort else 2drop then ; +: (abort") ( a u -- ) warn abort ; : abort" postpone s" postpone (abort") ; immediate compile-only \ ERROR MESSAGES {{{ @@ -324,6 +324,14 @@ privatise : evaluate ( a u -- ) tib @ >r #tib @ >r >in @ >r (evaluate) r> >in ! r> #tib ! r> tib ! ; + +: ?include-depth include-depth #buffers >= if + 0 to include-depth abort" too many input buffers" then ; +: include-file ( fd -- ) source-id >r ( fd ) dup to source-id + 1 +to include-depth ?include-depth + 0 cbuffer-used ! 0 cbuffer->in ! ( fd ) cbuffer-fd ! + begin refill while interpret repeat + 1 -to include-depth r> to source-id ; \ }}} \ \ VOCABULARY {{{ -- cgit v1.2.3