Re: [stack] sweetening concatenative syntax
John Nowak <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Mar 19, 2008, at 3:06 AM, John Nowak wrote:
> Here's another version of the above with a syntax more suited to a
> concatenative language:
>
> quad a b c = p n
> where 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 /
Or in a manner requiring less heroics for people with more taste and
sophisticated structural editors:
(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))
Unlike Manfred's original example, these return 'p' and 'n' on the
stack directly. '[...]' is just sugar for '(lambda () ...)', where
'lambda' expands to point-free code if variables are introduced.
Yes, I want a typed Scheme where functions can easily produce (and
subsequently consume) multiple values. Is that so wrong?
- John