4 ms·
Which problem?
by junke 10y ago
Which problem?
- __s 10y agoGive me lazy evaluation & I can define if as a function which takes 2 expressions & evaluates only 1, whereas in an eager language I'd have to pass a hand rolled if function callbacks
- deleted 10y ago[deleted]
- pklausler 10y agoFor example, Haskell's ifThenElse is just a normal function of three arguments.
- junke 10y 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 10y 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!