Re: [stack] disallowing recursive definitions
Manfred Von Thun <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <C4071143.F8C%[email protected]> |
On 12/3/08 3:19 AM, "William Tanksley, Jr" <[email protected]> wrote: > Manfred Von Thun <[email protected] <mailto:m.vonthun%40latrobe.edu.au> > > wrote: > >> > But as remember, continuation passing means giving >> > a procedure an additional parameter which represents the >> > rest of the program, and which will normally be executed >> > before the procedure returns. Landin¹s papers from the 60¹s >> > (and at least one much later) are good on this. Look for >> > ³History of continuations² or similar. > > Joy doesn't have any functionality which is like this. Forth does, > with its direct access to its return stack. > Not so. In Joy all parameters are taken from the stack. Combinators expect quotations, and quotations are also good as continuation parameters. I have used it a number of times to implement backtracking (in the only way I know: with continuations.) There is one file in the Joy library http://www.latrobe.edu.au/philosophy/phimvt/joy/plglib.joy > which does what are variously called truth trees, semantic tableaux or Wang¹s algorithm. Most of the programs in that file are annotated as expecting t f c F on the stack, with F on top. F is a formula in propositional logic which the tree method tries to make true (or false) by assigning truth to some atoms (in t) and falsity to others (in f). The c parameter is the continuation, and it does all the hard work of the backtracking. So, because Joy has quotations, no extra mechanism is needed to implement continuations. > John Cowan was right about the abandoned cont operator. It turned out that quotations can do the job. However it may also be that a different cont operator might make backtracking programs easier to read. > Incidentally, the mainstream languages which allow procedures as continuations will also allow several continuations. That is true in Joy too. I seem to remember that the implementation of Snobol (and maybe of Icon) used two continuations: one for success, the other for failure. - Manfred [Non-text portions of this message have been removed]