aboutsummaryrefslogtreecommitdiff
path: root/blog/stem.org
diff options
context:
space:
mode:
Diffstat (limited to 'blog/stem.org')
-rw-r--r--blog/stem.org27
1 files changed, 27 insertions, 0 deletions
diff --git a/blog/stem.org b/blog/stem.org
index ff9806f..ba65a4e 100644
--- a/blog/stem.org
+++ b/blog/stem.org
@@ -369,3 +369,30 @@ the language evolves, however, it becomes ever more easy to "talk" about abstrac
right of the previous quote, nesting quotes like russian dolls over and over again until it becomes suitable to call ~eval~. Thus, we have built up
a piece of code in the language and then automatically executed it! Note that because ~def~ is also a word, you can automatically define words as well,
which is a powerful concept.
+
+* C FLI
+The C "FLI" (I don't know what it is really) is a system by which custom objects and functions can be added into the language. A library which implements
+the bindings for this language have to implement the following functions:
+#+begin_src C
+void add_funcs();
+void add_objs();
+#+end_src
+and has to include the ~stem.h~ file as a library. The C file has a couple of global variables that it must recognize with extern:
+#+begin_src C
+extern array_t *STACK;
+extern array_t *EVAL_STACK;
+extern ht_t *WORD_TABLE;
+extern parser_t *PARSER;
+
+extern ht_t *FLIT;
+extern ht_t *OBJ_TABLE;
+#+end_src
+not all of these have to be used but it is a complete list of global variables. You may use ~add_func~ and ~add_obj~ (defined in stem.h) to add custom functions and custom
+objects. As long as an object has a specified way to free, deep copy, and create itself, it can be used in a memory safe manner.
+
+The builtin word ~clib~ loads a library dynamically and calls both ~add_func~ and ~add_obj~, adding all the functions and objects you've defined to the runtime environment.
+Note that when making custom functions, they must be in the form ~void my_func(void *value)~, where ~value~ contains the word that is used to call the function. When you
+are implementing functions, make sure to keep only one copy of a pointer on the stack at all times, otherwise it is prone to segfaulting. Also, for examples on how builtins
+may be implemented, see ~builtins.c~.
+
+Again, you can view the API at the [[https://stemdoc.nullring.xyz][webpage generated by doxygen]].