Hi!
So before I made a mess with my toy Lisp, could someone point to an
existing implementation of such thing in Lisp, possibly a description of
some ancient dialect?
But if you are looking for an example, you could look at the SBCL code
for the function SB-DEBUG:LIST-BACKTRACE.
For example, in a
simple case of a self-recursive function traversing a tree, the path in
the tree is already there, in the stack, and there's no need to save it somewhere else.
AIM-443: what stack is it that you imagine exists?This document looks ancient.
Yes, was a long time ago (years before I was born) that people worked out that function call and GOTO can be the same thing. From this came
everything like CPS conversion etc. CPS programs simply have no stack, at all: no function call ever returns so all function calls are now GOTO.
(kfact 4 (lambda (x)(id (* x 5))))
(kfact 3 (lambda (x)((lambda (x)
(kfact 2 (lambda (x)((lambda (x)
(kfact 1 (lambda (x)((lambda (x)
((lambda (x)((lambda (x)
But like everything people still live in their heads in a world of
clockwork PDP-11s, because that world is easier to understand than the real one.
This document looks ancient.
Yes, was a long time ago (years before I was born) that people worked out that function call and GOTO can be the same thing. From this came
everything like CPS conversion etc. CPS programs simply have no stack, at all: no function call ever returns so all function calls are now GOTO.
But like everything people still live in their heads in a world of
clockwork PDP-11s, because that world is easier to understand than the real one.
Yes, was a long time ago (years before I was born) that people worked out that function call and GOTO can be the same thing. From this came
everything like CPS conversion etc. CPS programs simply have no stack, at all: no function call ever returns so all function calls are now GOTO.I thought the Steele's paper is against GOTO.
So before I made a mess with my toy Lisp, could someone point to an existing implementation of such thing in Lisp, possibly a description
of some ancient dialect?
Arseny Slobodyuk <arseny@mail.org> wrote:at
This document looks ancient.
Yes, was a long time ago (years before I was born) that people worked out that function call and GOTO can be the same thing. From this came
everything like CPS conversion etc. CPS programs simply have no stack,
all: no function call ever returns so all function calls are now GOTO.
But like everything people still live in their heads in a world of
clockwork PDP-11s, because that world is easier to understand than the real one.
In terms of programming, the problem with continuations can be
represented by the following: if your functions never "return",
then how do you write the initial continuation?
I think what you really want is called a zipper data structure, which is something like a reified stack pointing into a tree or other such
object.
https://en.wikipedia.org/wiki/Zipper_(data_structure)
Looks suspiciously like a stack to me.
Nils M Holm <nmh@ananda.local> wrote:
Looks suspiciously like a stack to me.
Yes. Any program which has a list of things still to do must have a list
of things still to do. But it is not just a stack: it is a first class object which can be invoked or not invoked, or invoked several times. Is much more than a stack.
As you noted yourself, as long as you want to suspend one thing
in order to do another, you will need a stack. No matter how
clever the abstraction, you cannot get rid of it.
everything like CPS conversion etc. CPS programs simply have no stack, at >> all: no function call ever returns so all function calls are now GOTO.
I thought the Steele's paper is against GOTO.
My, what a struggle it was. I'm still afraid to use GOTO, though
Yes, was a long time ago (years before I was born) that people worked out
that function call and GOTO can be the same thing. From this came
everything like CPS conversion etc. CPS programs simply have no stack, at >> all: no function call ever returns so all function calls are now GOTO.
But like everything people still live in their heads in a world of
clockwork PDP-11s, because that world is easier to understand than the real >> one.
[ Drifting off-topic: ]
There are other points of views for which continuations aren't "real".
E.g. call/cc corresponds (in the Curry-Howard isomorphism) to the law of >excluded middle (LEM), which is a standard axiom of classical logic but
is the main axiom not included in constructive logic because LEM gives
you access to proofs which can't be constructed ("aren't real").
[ The deceptive part of it is that LEM is rarely really needed: you
don't need the LEM axiom to prove that integers are either odd or
even, and indeed for most such "either/or" you can actually prove
the proposition without having to resort to an axiom. ]
Stefan
I have this thesis about Cauchy rows in intuitionistic mathematics.
Basically you can replace
There exist an epsilon such that ..
by
It is impossible that there does not exist an epsilon ...
and you are good to go. This makes me think that evading the excluded
middle is mostly a boring exercise.
I don't understand how call/cc translates into the LEM, but I've seen
that stated before, so I hope to understand it someday.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 85:39:49 |
Calls: | 6,658 |
Files: | 12,203 |
Messages: | 5,333,708 |