0

I have defined these alias in user.r

alias 'powershell "pw"
alias 'explorer "o"
alias 'open-program-files "pf"
alias 'cmd "dos"
alias 'edituser "eu"
alias 'run-firefox "fx"
alias 'run-firefox "f"

When launching rebol it shows

** Script Error: Alias word is already in use: f
** Near: alias 'run-firefox "f"

This is not true, in fact when I type source f it says undefined:

>> source f
f: undefined
>>

So why this message ?

Rebol Tutorial
  • 2,738
  • 2
  • 25
  • 36

2 Answers2

1

Sadly, REBOL's ALIAS has a severe weakness, at least in R2: it works only globally.

So if any process has used a word already, it is not available for ALIASing.

Now, you have not defined it. But if you check the total works already defined when you start a fresh console, you may be surprised to see there are several thousand of them:

 print length? first system/words

And (at least with the version of R2 I just tried it on), that includes the word f:

find first system/words 'f

Even though f has no current value, the mere fact that it has been previously uses stops it being used with ALIAS.

ALIAS is a strong candidate for removal in R3 because of this (and other) limitations in its use.

Sunanda
  • 1,555
  • 7
  • 9
  • Hi thanks that's interesting. If it removed from R3, hope it will get back later with a more robust version because it would be a missing feature compared to Powershell aliases as Rebol is typically good for "Admin Development Model" see http://blogs.msdn.com/powershell/archive/2007/01/01/the-admin-development-model-and-send-snippet.aspx – Rebol Tutorial Sep 13 '09 at 14:43
  • There's a detailed discussion of the future of ALIAS here: http://www.rebol.net/r3blogs/0242.html It still has some chance of surviving in a better state under R3. – Sunanda Sep 14 '09 at 14:15
  • "I am one of the people who have only used ALIAS enough to produce bug reports.... " :D Well I seem to have encountered another weird bug : when I load a script which create a function which call an alias. Not sure it always happen systematically will have to check again. – Rebol Tutorial Sep 16 '09 at 19:32
0

As the Rebol dictionary says: Be careful not to confuse alias with setting another word to the same value.

alias is another overlooked feature of Rebol. If you just need to add new names to reference existing global values (including functions), you can just do it directly without alias:

pw:  :powershell
o:   :explorer
pf:  :open-program-files
dos: :cmd
eu:  :edituser
fx:  :run-firefox
f:   :run-firefox

alias will allow you to create a new symbol which will behave identically to the original one. We are talking here about symbols spelling equivalence, not words meaning equivalence (the eventually referred value). One of the most useful usage for aliasing, is translation of words which can be used as drop-in replacements for the original ones. For example:

>> alias 'monday "lundi"
== lundi
>> 'monday = 'lundi
== true
>> find [friday monday sunday] 'monday
== [monday sunday]
>> find [friday monday sunday] 'lundi
== [monday sunday]

As you can see, using an aliased word, allows you to create different spellings for the same word, so aliases can be processed by the same code without having to change it.

Aliased words could also be useful to create shortcut words for some dialects, though I do not know any dialect of Rebol so far which leveraged that feature.

PS: lundi is the French word for monday.

DocKimbel
  • 3,127
  • 16
  • 27