1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-27 13:47:42 +00:00

Change syntax for namespaces.

Add quasiquote, unquote, and unquote-splicing
as specials rather than a macro.
This commit is contained in:
Calvin Rose
2018-11-30 22:49:21 -05:00
parent 25c50f5026
commit 4e4dd31164
28 changed files with 678 additions and 609 deletions

View File

@@ -9,17 +9,17 @@
returns the result of the last expression. Will only evaluate the
body once, and then memoizes the result."
[& forms]
(def $state (gensym))
(def $loaded (gensym))
(tuple 'do
(tuple 'var $state nil)
(tuple 'var $loaded nil)
(tuple 'fn (array)
(tuple 'if $loaded
$state
(tuple 'do
(tuple ':= $loaded true)
(tuple ':= $state (tuple.prepend forms 'do)))))))
(def state (gensym))
(def loaded (gensym))
~(do
(var ,state nil)
(var ,loaded nil)
(fn []
(if ,loaded
,state
(do
(:= ,loaded true)
(:= ,state (do ;forms)))))))
# Use tuples instead of structs to save memory
(def HEAD :private 0)