3 ms·
Also R and I think were mostly in agreement here. However I'm of the opinion that more than just these languages (languages with lazy evaluation or macro's) are
by Bootvis 14y ago
Also R and I think were mostly in agreement here. However I'm of the opinion that more than just these languages (languages with lazy evaluation or macro's) are decent and that in for example Ruby there are differences between if and a function, as this example shows (my first lines of Ruby)
def iff(cond, x, y)
if cond then
x
else
y
end
end
puts iff(true, 1, puts('2'))
echoes
2
1
if may behave as a function, but you can't write a function that acts like if.
edit:
R does have real lazy evalution, e.g.
> iff <- function(cond, x, y) { if (cond) x else y }
> iff(TRUE, 1, cat('foo'))
[1] 1