From 54ac5e763cc26aee8c6fc9502398ce7b61281ec8 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Mon, 14 Sep 2026 20:57:48 -0700 Subject: place a trap inside the hex-transformed nlabel-transform-one this will be used to cause it to apply a tilde alternate, but the lexing code for that needs to be refactored first also, this has an implementation of nexit, a new flow-control word for a scary style of metaprogramming Force-Push: yes Change-Id: Ic7fe2d50a8ee21cf9fa5fef1fef4408c2935bb4c --- flow-control.e | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'flow-control.e') diff --git a/flow-control.e b/flow-control.e index bee5038..25a1931 100644 --- a/flow-control.e +++ b/flow-control.e @@ -127,3 +127,25 @@ 6 8 * + swap drop + swap drop -1 * , ; make-immediate + +~ This is a helper which does non-local exit by directly overwriting the +~ control stack, then calling regular "exit" (implicitly as part of its own +~ semicolon). The name "nexit" is short for n-exit, meaning that it takes a +~ parameter which tells it how many times to exit. +~ +~ 1 nexit is equivalent to regular "exit". 2 nexit is equivalent to asking +~ your own caller to exit. 0 nexit does nothing. +~ +~ This style of programming isn't encouraged, but may be useful when doing +~ code that transforms other code. +~ +~ This is much lower-level than the other flow-control stuff, but it isn't +~ compatible with the label transform due to relying on r0, so it needs to go +~ somewhere other than core.e, and this was the closest fit. +~ +~ Anecdotally, this feature is traditionally called "shunt", and sometimes +~ "rdrop". +~ +~ (count --) +: nexit 8 * control@ + r0 @ min control! ; + -- cgit 1.4.1