1
0
forked from alex-eg/sex

add support for begin in Sex

begin-wrapped blocks are now creating lexical scopes
This commit is contained in:
2025-08-14 14:33:14 +03:00
committed by Pavel Kulyov
parent 8ad5abf055
commit 78977e988e
4 changed files with 11 additions and 9 deletions

View File

@@ -38,9 +38,10 @@
(pub defmacro (list-for-each list-type list-var elt-type elt-var what-do)
(let ((list-var-2 (cat list-var '-2)))
`((var (pointer ,list-type) ,list-var-2 ,list-var)
(var ,elt-type ,elt-var (-> ,list-var-2 value))
(while (!= (-> ,list-var-2 next) NULL)
,what-do
(= ,list-var-2 (-> ,list-var-2 next))
(= ,elt-var (-> ,list-var-2 value))))))
`((begin
(var (pointer ,list-type) ,list-var-2 ,list-var)
(var ,elt-type ,elt-var (-> ,list-var-2 value))
(while (!= (-> ,list-var-2 next) NULL)
,what-do
(= ,list-var-2 (-> ,list-var-2 next))
(= ,elt-var (-> ,list-var-2 value)))))))