Re: [stack] function/object ambiguity + quotation alternative
John Nowak <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Mar 3, 2009, at 12:06 PM, William Tanksley wrote:
>> The nesting in
>> Scheme helps visually and things remain mostly understandable even if
>> you don't know the arities of all the functions involved. That's only
>> my opinion of course; I've not launched a study to determine if this
>> goes for most people, although I suspect it does.
>
> Forth is the only concatenative language we've discussed that lacks
> nesting. Why would you list "nesting" as an advantage of associative
> languages?
I was being sloppy. I've certainly proposed "concatenative" languages
with as much nesting as you find in Scheme.
I really was meaning to compare idiomatic ways of writing code in
concatenative languages. Take the following code for example:
foo bar [baz] dip quux
You will, in practice, get concatenative code like this. Now compare
to what might be the applicative equivalent:
(let ([(x y z) (foo input)]
[(b c) (baz y z)])
(quux (bar x) b c))
Here, it's clear that foo returns three values, bar only cares about
one, baz only cares about two, bar uses the first result of foo, baz
uses the second two, baz is independent of bar, quuz uses one result
from bar and two from baz, etc.
Getting all of this information out of the concatenative version isn't
possible. Does bar use one value? Two? More? What about quux? Does baz
depend on the result of bar? All of this is clear in the applicative
version but not the stack-based concatenative version.
Again, in practice, I occasionally find this difficult when writing
code quickly to prototype something. If you don't, then I certainly
won't call you a liar. Perhaps I just have Scheme burned into my head.
- John