[R] 'closure' (was "stats:: spline's method could not be monoH.FC")

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Thu May 7 00:05:15 CEST 2020


> OTOH, Hadley Wickham has written a book "Advanced R"  which has been
> the best book about advanced R by far (in my view, notably
> before it morphed (towards the 2nd edition) to use more and more
> non-base R packages).  There, he used "Closure" in a different,
> stricter sense, starting the section  'Closures' with
>     “An object is data with functions.
>      A closure is a function with data.” — John D. Cook

Martin, Thank you,

I've reviewed everything, and I've come to the following conclusion:
In general, a self-referencing function is not a closure, as such; and
In general, a closure is not a self-referencing function, as such.

So, to describe the superset, maybe I should say something like:

    *Self-Referencing Functions and Closures*

Also, I support multi-paradigm programming, including some global
state data mainly for default formatting-related options.
But if I understand things correctly, you support (or at least have
some preference for) purely-functional programming.
Which is one area, where we diverge.

It seems to me, the most people who advocate closures prefer
purely-functional programming.

If we use the principle, that in purely-functional programming, the
output of a function is not dependent on mutable state data, then
wouldn't it be better to say something like:

A closure is a function with (preferably non-mutable) data.


P.S.
If anyone's interested in creating R functions that reference
themselves, look at:
base::sys.function

Also, my package intoo contains convenience functions (THIS, THAT and
THEN), that wrap sys.function, giving it a slightly more
object-oriented flavor, and explore this idea further.
However, re-reading my documentation, I note that my examples need
some improvement...



More information about the R-help mailing list