Re: [stack] Barebone implementation of concatenative language in c or c++
<[email protected]> Wed, 19 May 2010 12:16:06 -0500
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 19 May 2010 11:57:21 -0500, <[email protected]> wrote: > Even if your language is eager and you're not considering parallel > combinators, there are still benefits to the applicative approach. In > particular, you can reduce and transform 'f x' in strictness-preserving > ways without worrying about the arity of 'g x'. This is useful when doing > algebraic manipulation of programs regardless of your evaluation mechanism. Final clarification. I mean you can apply rules like this without consideration for arity and coarity: cross f g . bi h i == cross (f . h) (g . i) where bi f g x = (f x, g x) cross f g x y = (f x, g y) This is equivalent to a rule like the following in Joy except for the fact that, of course, this rule isn't remotely valid: [H] [I] bi [F] [G] bi* == [H F] [I G] bi* where [F] [G] bi = [keep] dip i [F] [G] bi* = [dip] dip i It is, however, valid if all functions have a stack effect of ( x -- x ). Because the functions in the applicative version aren't lifted to operate on a stack, you don't have this issue. - jn