I needed a continue catcher, so I wrote one:
(syntax catch-continue ;; exprs...
(lambda (node compiler)
(let ((block [(import "Block") new])
(continue-label [compiler newLabel])
(index '1))
[[compiler continues] removeFirst]
[[compiler continues] addFirst: continue-label]
(while [index < [node size]]
[block add:
[[node at: index] translate: compiler]]
(set index [index + '1])
)
[block add: continue-label]
block
)
))
It works fine, except I had to make the compiler (I'm using jolt-burg)
expose "continues":
Compiler continues [^continues.]
Is there any chance of that getting into the official sources?
Here's a quick demo/test of how it's used:
(let ((i 0))
(while (< i 10)
(catch-continue
(if (== i 5) (continue))
(printf "%d\n" i)
)
(set i (+ i 1))
))
The "for" macro in syntax.k would also benefit from having a continue catcher.
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc