3 ms·
Syntactic forms ('frames', 'held arguments') are reasonably useful, but have two flaws: A. Understanding how to implement functions using syntactic forms is a
by bookofsand 5y ago
Syntactic forms ('frames', 'held arguments') are reasonably useful, but have two flaws:
A. Understanding how to implement functions using syntactic forms is a steep learning curve. I remember running out of dplyr and having to implement a udf. Fairly unpleasant experience (enquo, !!, perhaps other unusual constructs). Felt like programming C macros.
B. "A function can decide where variables are looked up however it likes" is a significant obstacle in understanding how even basic constructs like function calls actually work. There is a non-trivial amount of hard-to-debug dark magic lurking behind every corner.
A middle ground has never been achieved. For example, `plot(expr(x), expr(y1 + y2))`, where the system limits the dark magic to explicit uses of the `expr()` construct, and `expr(x)` always means `{vars: vars(x), expr: (vars(x)) => x}`. Instead of patching interpreter environments, simply call a lambda function.
- datastoat 5y agoI completely agree about the steep learning curve and the feeling of dark magic -- how many times have I had to relearn what deparse(substitute(x)) means -- but oh the satisfaction of broadening my programming horizons. For me it didn't feel like C macros, it felt like "This must be what it feels like to have the power of Lisp"! That's the weird thing about R. All this dark magic is hiding under the hood, but the core R team hid it so deftly that to the casual statistician it's a straightforward data modelling language that "just works". I'm not sure that it's possible to get rid of the dark magic and retain that data-modeller friendliness.