Re: [stack] function/object ambiguity + quotation alternative

John Nowak <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Feb 26, 2009, at 10:21 AM, Stevan Apter wrote:

>> This strangeness is more evident in the following example. The
>> expression '[dup swap] head' yields 'dup', but 'dup != [dup swap]
>> head'! This is because the left side of the equality is the  
>> *function*
>> 'dup', but the right side gets reduced to the *object* 'dup'.
>
> i've always assumed that [dup swap] head is the function dup.  e.g.  
> in XY:
>
>  2 [dup swap] first i
> 2 2
>
> that is, [dup swap] first leaves the function dup on the stack.
> then i moves the top item of the stack to the head of the queue.
>
> what am i missing?

I don't know XY, but XY does not work the same way as Joy and Factor  
apparently.

Factor:

    >> 5 { dup } first call
    Generic word call does not define a method for the word class.
    Dispatching on object: dup

Joy:

    >> 5 [dup] first i
    run time error: quotation as top parameter needed for i

This is the problem I'm referring to.

What XY does seems even worse though! Here's why:

    1. [dup] i == [dup] first i  (given, as per your example)
    2. [dup] == [dup] first      (removing shared 'i' suffix)
    3. id == first               (removing share '[dup]' prefix)

Certainly first cannot be the identity function! Is the algebra of XY  
broken? Am I missing something?

- 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.