Re: [stack] Re: K for Joy Programmers (paper), continuations

stevan apter — 2003-06-01 00:28:15

>
> BTW, have any of the vector techniques used in K been applied to
> text/file manipulation? I realize that K's forte is math, but I
> would think that treating strings as lists--or as trees--could
> provide some advantages over C-style strings in terms of flexibility,
> complex algorithms, especially for really massive agglomerations of
> text. (I'm just now starting to read the K reference on I/O, so, I
> don't know much about it.).

k might have a slight performance edge in text processing (see
http://www.kx.com/a/k/examples/bell.k for comparison with perl
and c on the bell labs scripting language benchmark), but to be
competitive in this area one would have to hook up one of the
standard regexp packages. as arthur is wont to say, k prefers
data processing (binary) to text processing.

on a slightly perpendicular matter, i've been skimming some
documents on continuations -- i think i understand the concept --
especially the work done on stackless python. very intriguing,
especially since the c-stack limits the number of recursions
one can perform in k. although it is pretty rare to hit the
limit (the ackermann function is a notable example), it is
annoying to have to worry about it, especially in a recursion-
intensive language like joy.

i see that call-cc has come and gone in joy, and i'm wondering
whether you (manfred) regard continuations as a piece of exotica,
or foresee it as being useful in joy.


>
> --Hodge
>

phimvt@lurac.latrobe.edu.au — 2003-06-02 04:00:38

On Sat, 31 May 2003, stevan apter wrote:

[..]

> i see that call-cc has come and gone in joy, and i'm wondering
> whether you (manfred) regard continuations as a piece of exotica,
> or foresee it as being useful in joy.

I have used continuations twice in Joy libraries: in the propositional
logic tableaux library 'plglib.joy', and in the grammar generating/
parsing library 'grmlib.joy'. Both use explicit continuations (=
quotations that may or may not be called) on top of the stack,
and both use them for backtracking: if success, call continuation,
else return. The initial continuation is a call to write some
value on the stack, and any successes change that value and some
also augment the continuation by some further goal to be achieved
before the write instruction is reached. (I had done that sort of
thing a lot in Pascal.)

Apart from explicit continuations like that, Joy still has an
operator 'conts' which pushes the current implicit continuations
on the stack - but the manual currently warns about its use.
It is harmless, and perhaps instructive, to put
conts putln
inside a program to see what outstanding implicit continuations there are.
I had hoped that I would find a use for it that could not be achieved by
explicit continuations. I have not thought about the topic for quite a
while, and for the time being I'll remain openminded. Any ideas?

- Manfred