3 ms·
That’s not that great of an example because you can do much the same with closures, which are seamless in some languages. In Scala for example, def cond[T]
by xmcqdpt2 2y ago
That’s not that great of an example because you can do much the same with closures, which are seamless in some languages. In Scala for example,
def cond[T](p: Boolean, a: => T, b: => T): T = if (p) a else b
will only evaluate one of the two arguments.
https://docs.scala-lang.org/tour/by-name-parameters.html https://docs.scala-lang.org/tour/by-name-parameters.html
You can do the same in Java with more syntax.
The real power of Lisp macro is that you introspect the code and modify it, not that you can alter evaluation eagerness.