Re: [stack] Joy's relationship to FP + a Joy variant with combining forms
John Nowak <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Jun 12, 2008, at 10:53 AM, William Tanksley, Jr wrote: > John Nowak <[email protected]> wrote: > >> In short, Joy is higher order and based on composition, and FP is >> first order and based on application. What I'm wondering is what a >> first order language based on composition would look like. >> >> One thing to note is that a combining form for quotation is no longer >> needed since it is impossible to create objects that represent >> functions. > > Hmm. So is Forth a first-order language based on composition? Roughly speaking, yes. Forth's words aren't pure in the same sense as functions are in Joy and FP, but if you ignore that, I'd say it qualifies. Forth also does have second-order combining forms such as IF and LOOP. Of course, they're not nearly as rich as they could be. > Seems that way. Mind you, Forth wasn't designed with that in mind, > so its > syntax is a hodge-podge, but it does seem like its semantics are > comparable. Ignoring side effects, I'd agree. >> Combining form version: >> reverse-map(F) = null fold(F cons) > > I'm thinking that this works using pure textual replacement. Is this > right? If so, this is a perfect match for Forth (and more regular than > the current Forth conventions). Yes and no. In 5th, reverse-map has its own type, and the expression given to it is type checked independently of reverse-map's definition. In other words, no expansion is necessary, and hence type inference remains local. In an untyped language like Forth, textual replacement would be a sufficient way of explaining things, although you may wish to share the code generated for the expression passed if it is used in multiple places (e.g. twice(F) = F F). > In short, I this looks like a nice model to give a concatenative stack > language disciplined access to its own source code. Or, in the 5th view, a disciplined way of manipulating its own functions. This is in contrast to Joy's "undisciplined" way of manipulation where you can write combinators that seem to be more than the sum of their parts. For example, it becomes possible to write things like '[dup i] dup i' that fail to terminate even though no recursive combinator was employed. Of course, "undisciplined" is a horribly loaded way of saying this. - John