Re: [stack] impure concatenativity: let without translation

John Nowak <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Mar 19, 2008, at 4:51 PM, Joe Bowbeer wrote:

> On Wed, Mar 19, 2008 at 11:58 AM, John Nowak wrote:
>
>> Postfix, as are *all* procedures. Only special forms are infix.
>> Perhaps this is a better declaration form:
>>
>>    (define (a b c quad)
>>       ...)
>>
>> - John
>>
>
> Better.  Better yet is:
>
>   (...
>      (a b c quad) define)
>
> This maintains a consistent right-to-left reading direction.  If  
> postfix is
> the "right thing," there's no such thing as too much, right?

There is. Special forms and macros need access to the entire tree to  
do their work. If you were to put 'define' at the end, then there's no  
way for it to act on the tree (without some bizarre backtracking).  
Keep in mind that even [a b c] is really (lambda () a b c). Putting  
meta-level things like 'define' and 'let' up front also aids in  
readability.

> Naive question: Is there any reason why concatenative languages are
> (uniformly) postfix?  Would prefix work just as well, pushing  
> elements onto
> the stack from right to left?

Let's say these two are equivalent:

    -- postfix
    hypot -> sqr swap sqr + sqrt

    -- prefix
    sqrt + sqr swap sqr <- hypot

Sure, both mean the same thing, but which is easier to read (provided  
you're used to reading left to right)?

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