5 ms·
R certainly has a lispish code-as-data element to it, but it seems like it has some serious flaws. Don't most lisps have functions and macros as separate constr
by vertere 8y ago
R certainly has a lispish code-as-data element to it, but it seems like it has some serious flaws. Don't most lisps have functions and macros as separate constructs? R has functions, but with some mucking around you can make them do macro-type stuff. Then people write these half-function, half-macro things (e.g. "non-standard evalation") that tend to break composability, either totally or sometimes only in edge cases.
- lispm 8y agoSomething like that would be called a FEXPR in Lisp. https://en.wikipedia.org/wiki/Fexpr https://en.wikipedia.org/wiki/Fexpr
- int_19h 8y agoLisps do that distinction because they need it. In R, you can do everything with functions, because arguments can be lazily evaluated, or you can even get the syntax tree used for that argument at call site instead. So in R, a macro is just a function. And yes, it's easy to break stuff that way. Just as easy as it is with macros (esp. non-hygienic ones).
- lispm 8y ago> Lisps do that distinction because they need it. Because of much better performance and predictability of code. See: http://www.nhplace.com/kent/Papers/Special-Forms.html http://www.nhplace.com/kent/Papers/Special-Forms.html
- int_19h 8y agoI'm not saying it's a better way to do things. It trades having fewer primitives (and hence simpler language structure) for performance. But the use of lazy evaluation is pervasive in R in general, so it's a conscious design decision that they made.