Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Re : Rebol language aliasing ==> was {Re: FORUM REBOL}

From: ingo:2b1 at: 21-Sep-2002 22:58

Hi Laurent, Am Sam, 2002-09-21 um 21.26 schrieb Laurent Giroud: <...>
> After reading this mail I did a few tests with the 'alias word to see if such > thing was feasible, but I went too fast and tried this : > > >> alias 'first premier ; premier is french for first > ** Script Error: premier has no value > > the error is logical since "help alias" reveals that alias expects a string as > its second argument. > So I retried (in the same console) : > > >> alias 'first "premier" > ** Script Error: Alias word is already in use: premier > >> premier [1 2 3] > ** Script Error: premier has no value > ** Near: premier [1 2 3] > > Isn't it a bug from 'alias ? It seems that premier was only partially registered as a > word by alias which renders correct further aliasing of that same word impossible.
Well, IIRC it is documented in the core guide, that 'alias can only alias to words, that have never been used before. Where "used" means it should never have been seen by rebol as a word, because the rebol interpreter saves everything it has seen as a word to system/words.
> But to answer back to Tim
<...> And now to answer forward to Tim ;-)
>> premier: :first >> t: [1 2 3 4]
== [1 2 3 4]
>> premier t
== 1 Of course, alias goes further than that ...
>> alias 'first "premier"
== premier
>> troisieme: :third >> premier [ 1 2 3 4 5 ]
== 1
>> troisieme [ 1 2 3 4 5 ]
== 3
>> rand-val: func[ s [ series! ] /first /third ] [ either first [ s/1 ][
either third [ s/3 ][ random/only s]]]
>> rand-val [ 1 2 3 4 5 ]
== 5
>> rand-val/first [ 1 2 3 4 5 ]
== 1
>> rand-val [ 1 2 3 4 5 ]
== 2
>> rand-val/first [ 1 2 3 4 5 ]
== 1
>> rand-val/third [ 1 2 3 4 5 ]
== 3
>> rand-val/premier [ 1 2 3 4 5 ]
== 1
>> rand-val/troisieme [ 1 2 3 4 5 ]
** Script Error: rand-val has no refinement called troisieme ** Near: rand-val/troisieme [1 2 3 4 5] Kind regards, Ingo