REBOL 3.0

Should we axe ALIAS?

Carl Sassenrath, CTO
REBOL Technologies
30-Aug-2009 18:59 GMT

Article #0242
Main page || Index || Prior Article [0241] || Next Article [0243] || 36 Comments || Send feedback

Does anyone use the alias function? If not, I propose that we drop it for 3.0.0.

For those who are not familiar with the alias function, it is used to define symbolic equivalence.

Ok, so what does that mean?

It is actually quite simple, but because no other language (that I know of) supports it, most programmers don't understand it. Symbolic equivalence is the concept that some symbol 'xyz is equivalent to some other symbol 'zyx. Which would allow this test to yield true:

>> 'xyz = 'zyx
== true

Why is this concept even in REBOL? There are two main reasons:

  1. To make uppercase and lowercase refer to the same word. 'XYZ = 'xyz, 'Xyz = 'xyz, and all other combinations.
  2. To allow word "synonyms" within a symbolic namespace.

Huh? What's a symbolic namespace?

It's a context (an object, module, etc.) -- where "symbols" are mapped to "variables" that reference "values"... which in REBOL is done dynamically, at any desired time, not just at load-time, compile-time, link-time, etc. Such contexts are at the core of REBOL's implementation.

So, in fact, you can write:

>> alias 'print "imprimez"
>> imprimez "hello world"
hello world

and this should not be misunderstood as being the same as:

>> imprimez: :print

which is value-equivalence, not symbol-equivalence. Here you are actually defining a new variable called imprimez and setting it to the function value of print. That's quite different.

Ok, so you ask again, why is it useful? Well, let's take the case where you've defined an object that has a print function within it:

>> obj: make object! [
     value: 123
     print: does [system/contexts/exports/print value]
]
>> obj/print
123

But, now, let's say you travel to Paris to visit Fran├žois at Sorbonne, and you want to be more friendly about your words, so you might write:

>> obj/imprimez
123

And you can see it works quite well! That result comes from the alias for print that was defined earlier. Keep in mind that what follows the obj/ is symbolically mapped -- its association happens very late in the evaluation process.

As you can see, it's kind of a nice concept, but it certainly isn't perfect. You can only define aliases when their words have not already been used. For instance, if you already defined or used a word imprimez before the alias, then it would not be allowed, because the word imprimez already has unique reference within a symbolic namespace.

Well, I must say that I'm not familiar with any programmers actually using the alias feature (not that anyone tells me much of anything unless it's a bug report), so perhaps it's just best to remove it from R3. Right now, during the massive effort to get 3.0 released, it's better to do less for now, but get the rest done sooner.

Perhaps you've seen a change in my attitude... considering how long it's taking to get R3 out the door!

36 Comments

REBOL 3.0
Updated 20-Apr-2017 - Edit - Copyright REBOL Technologies - REBOL.net