Re: [stack] impure concatenativity: let without translation

"William Tanksley, Jr" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
John Nowak <[email protected]> wrote:
> Just moments ago, I gave this example of the quadratic formula:
>    (define (quad a b c)
>      (let ((d b 4 a c * * -)
>            (r d 0 >= [d sqrt] ["quad: sqrt of negative" error] if)
>            (x 2 a *)
>            (p b r - x /)
>            (n b r + x /))
>        p n))

>  How it works should be obvious after you get used to looking at this
>  sort of prefix/postfix syntax.

I'd like to deal with this post in two parts: first, exploring the
interesting issues you raise, and second, <ironic>solving once and for
all</ironic> the pesky problem of finding the roots of a quadratic
equation in a concatenative language. I'll do the latter in a distinct
post.

IMO, this is a very nice convention for special forms such as define,
let, and others. It would in general make macros a lot less risky,
since their scope would be explicitly delimited.

To take this to an extreme, one could imagine making the parens
optionally switchable with xml-style notation; such notation is useful
when the special form spans a large block, as for example with Joy's
LIBRA form. One shouldn't do this for a small block, but just as an
example:

<define>(quad a b c)
    <let>(d b 4 a c * * - )
           (r d 0 >= [d sqrt] ["quad: sqrt of negative" error] if )
           (x 2 a * )
           <p> b r - x / </p>
           <n> b r + x / </n>
   </let>
      p n
</define>

The rules for the transform I used should be quite obvious, and I
failed to perform it in some places just to make it clear that it's
purely syntactic, totally optional, and has no semantic effect.

Such a syntax would be unbearable over short ranges (like in the 'let'
above), but I suspect it would be convenient over large syntatic
blocks -- and would make counting parentheses a thing of the past.

I started this as a joke; now I'm tempted to modify a Scheme
interpreter to see if it's realistic.

> It's a very nice way to write this
>  function; arguably nicer than what you can do in Scheme as the
>  multiple values returned can be easily consumed (or ignored) by
>  another function. For example, if we only cared about the positive
>  root, we could do 'quad pop'.

Agreed.

>  What I'm suggesting is that dropping any pretense of being purely
>  concatenative offers some clear usability benefits with no loss in
>  expressiveness.

The only loss is in referential transparency -- it's no longer true
that cut and paste is always precisely sufficient to perform an
"extract method" refactoring. BUT, frankly, that's not an unworkable
loss.

>  It would likely offer efficiency advantages as well;
>  splicing quotes together to embed variables into the middle of
>  anonymous functions is less than fun.

I wouldn't encourage doing that anyways, but it's true that some
problems lend themselves nicely to this type of solution.

>  Are there any other proposals for an impure (or, more nicely,
>  "hybrid") concatenative language out there?

> What are the negative practical implications of being impure?

The problem is that we don't know. I'd like to understand the negative
practical implications of being purely concatenative. I know they
exist.

>  - John

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