Skip to content

Instantly share code, notes, and snippets.

@nedzadarek
Created July 6, 2018 12:09
Show Gist options
  • Save nedzadarek/183ee6b713eac85ff9bc85a997e18405 to your computer and use it in GitHub Desktop.
Save nedzadarek/183ee6b713eac85ff9bc85a997e18405 to your computer and use it in GitHub Desktop.
Making words set by 'set' local - sample
func-set-local: func [spec body] [
locals: copy []
parse body [
to any ['set set w lit-word! (probe w) (append locals w)]
to end
]
func append spec compose [/local (locals)] body
]
f: func-set-local [a b] [set 'c (a + b) c]
f 1 2
c ; error - no global word - good
f-without-local: function [aa bb] [set 'cc (aa + bb) cc]
f-without-local 11 22
cc ; 33 ; global word set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment