Re: [stack] language hierarchy

Don Groves <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Dec 11, 2007, at 19:38 , William Tanksley, Jr wrote:

> Don Groves <[email protected]> wrote:
>> John Nowak wrote:
>>> This has the downside that functions cannot make use of explicit
>>> recursion (as hypot isn't defined until def is called, and hence the
>>> quote can't make use of it), but this restriction is in place anyway
>>> due to the type system.
>
>> How about "self" as a call to its enclosing context?
>
> It won't work for dynamic definitions, because there's no distinct
> concept of "enclosing context". All you know is that you're inside a
> quotation that's inside another quotation; you can't look ahead to see
> which enclosure is the one being defined and/or executed. There are
> several solutions:
>
> 1. Provide special syntax for quoted definitions (perhaps make them  
> compiled).
> 2. Provide recursion primitives like linrec, genrec, etc.
> 3. Provide partial continuations.
>
> #3 is especially interesting, since PCs can implement recursion or
> backtracking equally easily. In a typefree language, it's very simple
> to implement; in a typechecked language, of course, one additionally
> has to ensure that the word which begins the partial continuation is
> exposed to the same stack as the words which call it.

You're probably right on this but I'm not entirely convinced.  John said
"explicit recursion" which I take to mean calling a function from within
itself. This would seem to leave leave out 1. and 2.

Maintaining a pointer to the current enclosure should be sufficient for
self invocation. That would require another stack, of course, which may
be worse than having a simple solution to the problem. And using the
already existing recursive methods is more in line with concatenative
theory anyway, ..., so I'll forget about it ;-)
--
Don


>
>> Don
>
> -Wm
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.