Re: [stack] What does "concatenative" actually mean?

John Nowak <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Mar 3, 2009, at 5:17 PM, Robbert Dalen wrote:

>> I never claimed anyone ever claimed Joy was lazy. My claim was
>> essentially that, if Joy were purely functional in the same sense
>> Haskell was, you *could* evaluate it lazily if you wanted to. Given
>> that you cannot do so, I don't think it is correct to call it "purely
>> functional". The reason for this is that it does not have the  
>> property
>> that you can replace an expression with the result of evaluating it  
>> as
>> Haskell does (i.e. referential transparency). Such a property is what
>> enables sensible lazy evaluation.
>
> i think referential transparency doesn't mean that.
> it means that a function should always return the same output given
> the same input.

They're equivalent statements. If a function always returns the same  
output given the same input, then you can replace an application of  
that function to a given input with the output of that application.

In Joy, neither holds. A function like 'rand' is going to return  
different values given the same input. The only way to prevent this is  
to pass a world value through the program and have 'rand' require  
exclusive access to that world value in order to determine its output.  
The only way to do this sensibly (i.e. in a way that would permit  
arbitrary order reduction) is with a type system.

> and joy could be lazy

No it couldn't. Take the following example where 'print' takes a stack  
with a string on top and prints it to the screen:

    "foo" print "bar" print  (initial state)
    "bar" print              (eval '"foo" print')
                             (eval '"bar" print')

In order for this to have consistent behavior, you have to reduce in  
an eager manner.

Now take this example where 'print2' takes a stack with a string as  
the second item and a world value on the top and returns a new world  
as its result:

    "foo" `worldA print2 "bar" swap print2  (initial state)
    `worldB "bar" swap print2               (eval '"foo" `worldA  
print2')
    "bar" `worldB print2                    (eval 'swap')
    `worldC                                 (eval '"bar" `worldB  
print2')

- John
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.