Re: [stack] Barebone implementation of concatenative language in c or c++

"Ruurd" <[email protected]> Wed, 19 May 2010 07:15:38 -0000
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
> > Quotations. If A, B, C, D, E are valid
>  > programs and B == D E, then A B C ==
>  > A D E C and vice versa. That leaves the
>  > question: what is a valid program. The
>  > empty program is valid. A program that
>  > has a matching number of [ and ] is valid.
> 
> That's actually not true. For example, '+' is not a valid program. It's 
> a valid expression, but not every expression is a valid program.

I dón't see why + is not a valid program. When executed it will give a runtime error when there is nothing to add, but validity is a syntactic property. (I have not said so, but with [ and ] I mean the tokens, not the characters). Also, according to the grammar of Joy:
http://www.latrobe.edu.au/philosophy/phimvt/joy/j09imp.html
there is no such thing as an expression. There is only term and factor, a term being equal to zero or more factors. And a program is a term, of course.

> 
> > When this rule is followed it will not
>  > be possible to substitute within a
>  > quotation, because then I would have to
>  > choose in your example: A == [, D == 1,
>  > E == 2 +, C == ], B == 3; A and C are
>  >  not valid programs according to the
>  > definition.
> 
> I think you've misunderstood me. My point is that, for example:

No, I did not misunderstand you. I give rules that distinguish environments that allow substitution and environments where that is not allowed. It is not necessary to do substitution everywhere.

If A and B are valid programs, then so is A B. This rule allows me to make programs bigger. The substitution rule allows me to inline if I favor speed or to factor out if I favor program size. I don't see any reason why I would want to simplify within an abstraction.