Re: [stack] stackless fixed-arity concatenative languages

John Nowak <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On May 22, 2008, at 3:38 AM, John Nowak wrote:

> The kind people on #concatenative also pointed out that 'dup dip dip'
> behaves differently than the version of 'bi@' in Factor because it
> applies the quotation to 'y' first, not 'x'. In an impure language,
> these are obviously not equivalent. A definition that matches the
> semantics of 'bi@' in Factor is 'dup [ dip ] dip call', or '[ dip ]
> keep call'.

Last thought on this for tonight. I wanted to note that 'dup dip dip'  
is actually just plain wrong if you want to use it for quotations with  
arities beyond 1->1. For example, here's the Factor version of 'bi@'  
at work with a quotation of arity 1->2, 'dup':

    1 2 [ dup ] bi@
    1 2 [ dup ] dup [ dip ] dip call
    1 2 [ dup ] [ dup ] [ dip ] dip call
    1 2 [ dup ] dip [ dup ] call
    1 dup 2 [ dup ] call
    1 1 2 [ dup ] call
    1 1 2 dup
    1 1 2 2

As you can see, it applies 'dup' to both 1 and 2 as expected. Here's  
my broken version:

    1 2 [ dup ] bi@_broken
    1 2 [ dup ] dup dip dip
    1 2 [ dup ] [ dup ] dip dip
    1 2 dup [ dup ] dip
    1 2 2 [ dup ] dip
    1 2 dup 2
    1 2 2 2

Not so good. Anyway, if we use the /correct/ version of 'bi@' from  
Factor, my new system-in-progress can give it this rather nice looking  
type that very clearly shows what it does:

    $a [$B] -> $B $a $B

Maybe the trick to making n-ary combinators understandable is a more  
powerful system, not a more restricted one.

- John
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.