Skip to content

Instantly share code, notes, and snippets.

@endo64
Last active March 16, 2019 21:59
Show Gist options
  • Save endo64/f2affabe80bd344d1f68bce2e35d543a to your computer and use it in GitHub Desktop.
Save endo64/f2affabe80bd344d1f68bce2e35d543a to your computer and use it in GitHub Desktop.
CONTINUE support for FOREACH-FACE function
foreach-face: func [{Evaluates body for each face in a face tree matching the condition}
face [object!] "Root face of the face tree"
body [block! function!] {Body block (`face` object) or function `func [face [object!]]`}
/with "Filter faces according to a condition"
spec [block! none!] "Condition applied to face object"
/post {Evaluates body for current face after processing its children}
/sub post? "Do not rebind body and spec, internal use only"
/local exec continue ; <-- addition #0
][
unless block? face/pane [exit]
unless sub [
all [spec bind spec 'face]
if block? :body [bind body 'face]
]
if post [post?: yes]
exec: [either block? :body [do body] [body face]]
continue: does [throw/name none 'continue] ; <-- addition #1
foreach face face/pane [
catch/name [unless post? [either spec [all [do spec do exec]] [do exec]]] 'continue ; <-- addition #2
if block? face/pane [foreach-face/with/sub face :body spec post?]
catch/name [if post? [either spec [all [do spec do exec]] [do exec]]] 'continue ; <-- addition #3
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment