Re: [stack] are concatenative languages applicative?
John Nowak <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Apr 24, 2008, at 6:47 PM, John Cowan wrote:
> John Nowak scripsit:
>
>> What I'm interested in is this "dequotation" rule:
>>
>> [$A] i == $A
>>
>> In other words, these are all equivalent:
>>
>> 1 2 [3 * *] i == 1 2 3 * * == 1 [2 3] i [* *] i
>>
>> An important thing to note here is that this translation is just a
>> rewriting of function-level code. '$A' is a function, not a value.
>
> Well, yes and no. In Joy, at least, *everything* is a value, and
> every value may be applied to the stack. So [1 2 3] is the value
> "the list containing 1, 2, and 3" where 1, 2, 3, and the list itself
> are just values.
We need to be more careful. Joy programs are expressed entirely in
terms of functions. Joy is a function-level language. I'll give three
examples to make this clear:
- '[1 2 3]' is a *function* of type 'A -> A [B -> B Num Num Num]';
when evaluated, it pushes the *value* [1 2 3] of type '[A -> A Num Num
Num]' onto the stack
- '1 2 3' is a *function* of type 'A -> A Num Num Num'; when
evaluated, the *values* 1, 2, and 3 get pushed onto the stack
- '3' is a *function* of type 'A -> A Num', not a value of type 'Num'
as in Haskell or ML; when evaluated, the *value* 3 gets pushed onto
the stack
In short, even '3' is a function in Joy. This should be obvious as we
can assign a name to it:
foo = 3
Here, we're not binding 'foo' to the value of 3; we're declaring that
'foo' is a function that pushes '3' onto the stack. According, in the
expression 'foo foo +', we can substitute 'foo' for it's definition,
yielding '3 3 +', which then evaluates to '6'. Never at any point are
we manipulating values.
So this gets me back to my question...
- John