Created
July 6, 2018 12:09
-
-
Save nedzadarek/183ee6b713eac85ff9bc85a997e18405 to your computer and use it in GitHub Desktop.
Making words set by 'set' local - sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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