[Rd] callCC in 2.7.0
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Mar 30 19:30:23 CEST 2008
I came across this in googling for continuations and was surprised when
I found it in R 2.7.0 and since I had not come across it before I assumed
it was added just now.
Can you explain how its intended to be used with an example
that is more realistic than in the example section.
On Sun, Mar 30, 2008 at 1:14 PM, Luke Tierney <luke at stat.uiowa.edu> wrote:
> On Sun, 30 Mar 2008, Gabor Grothendieck wrote:
>
> > Also in trying it out again it seems that its not like
> > on.exit but more like return:
>
> Yes -- if you can point out what in the documentation ever gave the
> idea it might be like on.exit then we can fix the documentation.
>
> >
> > F <- function(f) { f(10); print(2); f(20); 3}
> > callCC(F)
> >
> > acts the same as:
> >
> > F <- function() { return(10); print(2); f(20); 3}
> > F()
> >
> > and there is no documented way to restart F
> > at the point it left off so I assume it can't.
>
> The documentation descriped this as a downward-only version -- that is
> standard terminology for a callCC that produces continuations that are
> no longer valid after the callCC call exits.
>
> Not sure why your original question was about "callCC in 2.7.0" -- I
> believe callCC was added in 2.5.0, the same time as codetools became
> recommended, and hasn't changed since. It is not a function every R
> user needs to have in their repertoire, but it can be very useful in
> some situations.
>
> luke
>
> > On Sun, Mar 30, 2008 at 12:34 PM, Gabor Grothendieck
> > <ggrothendieck at gmail.com> wrote:
> >> I think the only relationship to that is the name since
> >> it does not appear to allow one to leave a function
> >> in the middle of its processing and re-enter it back
> >> at that point -- which is what would be needed.
> >>
> >>
> >> On Sun, Mar 30, 2008 at 12:04 PM, <h.wickham at gmail.com> wrote:
> >>>
> >>>> Would anyone like to explain if callCC in R 2.7.0 gives
> >>>> anything that on.exit does not already provide?
> >>>>
> >>>> It seems that the exit condition once defined cannot
> >>>> be added to overridden whereas with on.exit multiple
> >>>> on.exit's add additional on.exits rather than being ignored.
> >>>>
> >>>> Is this important?
> >>>
> >>> It facilitates a completely different style of programming - see
> >>> http://en.wikipedia.org/wiki/Continuation-passing_style
> >>>
> >>> --
> >>> http://had.co.nz/
> >>>
> >>
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
> --
> Luke Tierney
> Chair, Statistics and Actuarial Science
> Ralph E. Wareham Professor of Mathematical Sciences
> University of Iowa Phone: 319-335-3386
> Department of Statistics and Fax: 319-335-3017
> Actuarial Science
> 241 Schaeffer Hall email: luke at stat.uiowa.edu
> Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
>
More information about the R-devel
mailing list