Re: [stack] impure concatenativity: let without translation

Robbert van Dalen <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
another postfix language with named 'variables' is enchilada.

<disclaimer>
this may seem like a shameless plug :)
or i haven't been talking about enchilada that much lately :(
</disclaimer>

anyway, i don't think 'variables' defy pureness. let's consider  
symbols instead.

symbols are placeholders for values to be. symbols can be bound so  
that they can be replaced by values.

consider the following postfix expression with unbound symbols:

x y + z *

how do we bind z?
to do this we enclose the expression with an enchilada 'macro' operator:

{z=x y + z *}
prefixing this macro with a value, binds symbol 'z:

4 {z=x y + z *}
x y + 4 *

a macro acts like a monadic operator, binding a value with it's  
internal expression at each reduction step.
in a sense, a macro fills in the blanks.

macros bind lexically, i.e.

1 2 3 {z={x={y=x y + z *}}}

reduces to:

1 2 3 {z={x={y=x y + z *}}}
1 2 {x={y=x y + 3 *}}
1 {y=2 y + 3 *}
2 1 + 3 *
3 3 *
9

another convenient (and operationally equal) form would be:

1 2 3 {y x z=x y + z *}
1 2 {y x=x y + 3 *}
1 {y=2 y + 3 *}
2 1 + 3 *
3 3 *
9

'replacing' a symbol with a value doesn't need to be destructive: it  
can be pure: just leave every expression untouched. use pure copy  
semantics all the time.

making copy semantics efficient and scalable: that's what enchilada is  
about.

<end-shameless-plug/>

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