3 ms·
For example, Haskell's ifThenElse is just a normal function of three arguments.
by pklausler 11y ago
For example, Haskell's ifThenElse is just a normal function of three arguments.
- junke 11y agoOkay, but the article has almost nothing to do with that, which is a subset of what macros are used for. It is about CL lexical binding, Rebol's definitional scoping and evaluation of data as code at runtime.
- draegtun 11y ago"IfThenElse" in Rebol (called either) is also just a function with 3 args: either 1 = 1 [print "true!"] [print "false!"] Here's an example of writing this in Rebol directly: if-then-else: function [ cond [logic!] true-block [block!] false-block [block!] ][ switch cond [ #[true] [do true-block] #[false] [do false-block] ] ] This works because blocks aren't evaluated until explicitly called: >> if-then-else 1 = 1 [print "true!"] [print "false!"] true! >> if-then-else 1 = 2 [print "true!"] [print "false!"] false!