Pierre Johnson napsal(a):
> A recent exchange on the REBOL email list made me revisit
> Ladislav Mecir's article "Rebol Words and Contexts, alias
> Bindology" 
>
> [http://www.fm.vslib.cz/~ladislav/rebol/contexts.html] 
>
> Mr.Mercir writes: 
>
> "Two words are equal, if they have equal spelling, or if they
> are aliases ... This knowledge can be used to define a Rebol
> function which can tell us whether two words are aliases."
>
> His word and definitional:
>
> aliases?: func [
>     {find out, if word1 and word2 are aliases}
>     word1 [any-word!]
>     word2 [any-word!]
> ] [
>     found? all [
>         equal? :word1 :word2
>         not equal? spelling :word1 spelling :word2
>     ]
> ]
>
> which depends upon:
>
> spelling: func [
>     {return the spelling of a word}
>     word [any-word!]
> ] [
>     if word? :word [return mold word]
>     if set-word? :word [return head remove back tail mold :word]
>     next mold :word
> ]
>
> But is this truth? 
>
> Two words are aliases if, 
>
> 1. if the words are not the same -- either one does not point to
> the other or one does not point to the same definitional to
> which the other points
>
> - and -
>
> 2. the two words are equal -- one copied the definitional of the
> other using ALIAS at some earlier point
>
> aliases?: debate [
>       word1 [any-word!]
>       word2 [any-word!]
>       ][
>       either (not same? word1 word2) and (equal? word1 word2) [
>               true
>       ][      
>               false
>       ]
> ]
>
> test: 
>
>   
>>> alias 'func "def"
>>>       
> == def
>
>   
>>> aliases? 'func 'daf
>>>       
> == false
>   
>>> aliases? 'func 'def
>>>       
> == true
>
>   
>>> a: 23
>>>       
> == 23
>   
>>> b: :a
>>>       
> == 23
>   
>>> aliases? 'a 'b
>>>       
> == false
>
>   
>>> c: 23
>>>       
> == 23
>   
>>> aliases? 'a 'c
>>>       
> == false
>
>   
>>> alias 'a "aa"
>>>       
> == aa
>   
>>> a
>>>       
> == 23
>   
>>> aa
>>>       
> == 23
>   
>>> aliases? 'a 'aa
>>>       
> == true
>
> Thoughts?
>
> Pier
>
>
> ________________________________________________
> Get your own "800" number
> Voicemail, fax, email, and a lot more
> http://www.ureach.com/reg/tag
>   
you encountered one "unusual" REBOL property - aliases. See this:

    alias 'a "aa"
    a: 4
    aa ; == 4
    aa: 5
    a ; == 5

The same does not hold for any pair of words referring to the same value 
(which we don't call aliases in REBOL)

HTH
-L

-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to