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

2020-05-06 Thread Abby Spurdle
On Thu, May 7, 2020 at 4:50 PM Mark Leeds wrote: > Richard: I may have implied that one should "mess with environments" by > saying that I agree with Abby. If so, my apologies because that's not what I > meant. > I only meant understanding. Hi Mark, I don't think you need to apologize. Accordi

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

2020-05-06 Thread Mark Leeds
Hi Richard: I didn't say it was and didn't mean to imply it. All I said is that it was an example of where "not understanding environments" can lead to errors that won't be understood by the person experiencing them. It just so happens that the use of "environment(f) <- " can lead to a solution

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

2020-05-06 Thread Richard O'Keefe
I should clarify that the original *problem* wasn't a case of environment()<- but a proposed solution was. As the proposer wrote, "However, this can lead to headaches downstream". We agree that it is very important and useful to understand environments in R. I once set out to construct a formal m

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

2020-05-06 Thread Mark Leeds
Richard: I may have implied that one should "mess with environments" by saying that I agree with Abby. If so, my apologies because that's not what I meant. I only meant understanding. On Thu, May 7, 2020 at 12:47 AM Mark Leeds wrote: > Hi Richard: I didn't say it was and didn't mean to imply i

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

2020-05-06 Thread Richard O'Keefe
That example is NOT an example of "messing around with environments." On Thu, 7 May 2020 at 15:36, Mark Leeds wrote: > > Hi Abby: I agree with you because below is a perfect example of where not > understanding environments causes a somewhat > mysterious problem. Chuck Berry explains it in a fol

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

2020-05-06 Thread Richard O'Keefe
By "mess around with" I mean environment(f) <- ... That is for _very_ advanced players. Never assume that someone meant something stupid, make them prove it. On Thu, 7 May 2020 at 15:28, Abby Spurdle wrote: > > > If you want to mess around with the environment of a > > function, then you need t

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

2020-05-06 Thread Mark Leeds
Hi Abby: I agree with you because below is a perfect example of where not understanding environments causes a somewhat mysterious problem. Chuck Berry explains it in a follow up email. https://r.789695.n4.nabble.com/issues-with-environment-handling-in-model-frame-td4762855.html On Wed, May 6, 2

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

2020-05-06 Thread Abby Spurdle
> If you want to mess around with the environment of a > function, then you need to understand this stuff, but you probably > shouldn't do that. What exactly do you mean? Are you implying that a user should not use environments? In which case, I would disagree. __

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

2020-05-06 Thread Richard O'Keefe
A closure is a function plus an environment. That's it. This is a sixty-year-old thing in programming languages. A closure is a dynamic value representing an instance of a function in a particular context which it can refer to. When a program in Algol 60 passed a procedure P to a procedure Q, w

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

2020-05-06 Thread Abby Spurdle
> 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 sec

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

2020-05-04 Thread Martin Maechler
Just about this one some important term 'closure', hence I'm modifying the subject. Note we came here from my 2nd reason why I had added 'monoH.FC' feature only for splinefun() and not for spline() : - splinefun() is using's R feature of "(non-trivial) closure", i.e, it returns a *function*