From e442729e05bbe1332f6536152d2baa29b60e01c5 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Tue, 28 Jan 2025 16:46:17 +0100 Subject: [PATCH] skipped if idea --- examples/if.slc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/if.slc b/examples/if.slc index 35ab44f..73eb679 100644 --- a/examples/if.slc +++ b/examples/if.slc @@ -60,3 +60,17 @@ gen(zero) branchcall ; + +// Alternatively I can just add a "branchskip" to the list of predefined words and way to just count words and geninline(..) +::builtin if + geninline() + genpush(_) + countwords{} + genpush(_) + countwords[] // returns 0 if there was no block (its SKIP to 'branchskip' 0) + genpush(_) + gen(branchskip) +; + +// This is not only simpler, but one can implement branchcall via a tiny bit of branchskip and a call to be honest... +// Also I feel like this results in bytecode with much better cache locality.