# stack operations vs function transformation

## stevan apter — 2005-04-09 11:41:37

    ----- Original Message -----

    From: "Ivan Tomac" <e1_t@...>

    To: <concatenative@yahoogroups.com>

    Sent: Friday, April 08, 2005 10:00 PM

    Subject: [stack] Re: Parsing in concatenative languages

    >

    >

    > --- In concatenative@yahoogroups.com, "William Tanksley, Jr"

    > <wtanksleyjr@g...> wrote:

    > > It sounds correct to me that S and K are complete, which means that

    > > using them you can construct all of the possible parameter reorderings

    > > you could ever need in order to operate in a completely point-free

    > > style.

    > >

    > > So, therefore, it sounds incorrect to me to claim that "flip is

    > > impossible to write in point-free style". Is that correct?

    > >

    >

    > Yes, I was wrong there. My initial thought was that to solve the

    > problem you'd have to write a domain specific language on top of

    > Haskell (like the stack+dip idea or what Stevan suggested with the

    > arguments being passed in a list and then having a set of shifting and

    > swapping combinators to reorder the arguments) and I thought it would

    > be the same with the S K combinators but after looking at the S K

    > combinators again it seems it's possible with just plain Haskell

    > functions and no other abstractions.

    L, R, and S (used to be X) shift and swap the arguments of a function.

    you can also have D (dup) and P (pop), which operate this way:

    let t be the following function of three arguments:

        t:{[a;b;c]a+b*c}

        D t

      {[a;b]a*b+b}    / note that D modifies the function body as well

        P t

      {[a;b;c;d]a*b+c}

    compare:

        2 5 dup + *

      20

        D[t]. 2 5

      20

        2 3 4 5 pop + *

      14

        P[t]. 2 3 4 5

      14

    in http://www.nsl.com/k/f.k

    now i wonder whether it is possible to construct a language in which

    the stack is entirely "virtual", and all data-movement is replaced

    by the transformation of functions.

    >

    > > -Billy

    >

    > Ivan

    >

    >

    >

    >

    >

    >

    > Yahoo! Groups Links

    >

    >

    >

    >

    >

    >

    >

## William Tanksley, Jr — 2005-04-09 15:59:36

    stevan apter <sa@...> wrote:

     > now i wonder whether it is possible to construct a language in which

    > the stack is entirely "virtual", and all data-movement is replaced

    > by the transformation of functions.

     Sure, or so I'd think. It seems like an extension of optimization --

    although taken to such an extent that it probably wouldn't be optimal

    anymore.

    -Billy