ldfgldftgldfdtgl
df_
_
dfiff1_crank_f
you can parse it out for the reader, as something like "l" 'set-non-delim eval
"gl" 'set-non-delim eval
"tgl" 'set-non-delim eval
"dtgl"
"\n" 'set-non-delim eval
"_\n"
"_\n" 'set-non-delim eval
'set-ignore eval
eval
and so on. Or maybe even (set-non-delim "l")
(set-non-delim "gl")
(set-non-delim "tgl")
(set-non-delim "dtgl")
(set-non-delim "_\n")
(set-ignore "_\n")
(dtgl)
and only then you'd go through the source, character by character. Just because the source is hard to read by humans, doesn't mean we need to stick to it in an explanatory example. foo bar baz
will call the 3 functions in order 1 1 + print
just translates to 1()
1()
+()
print()
Function names do not have to start with a letter or be alphanumeric. I've happened to name my function so that those ending in a colon treats the next token to the right as a string instead of a function call. The [ function treats everything as strings until ] (that is a single close square bracket as a token) and puts the function in those body in a quote, effectively creating an anonymous function. So def somename():
foo()
bar()
baz()
And you can later call somename in later functions. sum([x*x for x in range(10)])
as "desugaring" to sum(list_comp(lambda(x, quote(multiply(x, x))), range(10)))
which looks like Lisp if you move every open parens one token to the left and remove the commas (sum (list_comp (lambda x (quote (multiply x x))) (range 10)))
To evaluate this, parameters are first recursively evaluated (in order) and then the function is called on the outer value. Let's ignore the lambda for the moment. (sum (list_comp quoted_inner_func (range 10)))
results in the following function calls are made at execution time _in this order_ quoted_inner_func 10 range list_comp sum
Normally, you'd have to pass the correct parameter to each function. However, in Forth, we use a global parameter stack so provided all the functions respect their inputs and output, running the above body would provide the desired result on the parameter stack!
blog.asrpo.com
Contact: asrp email com