I'm using Rebol/Core 278-3.1 on Win-7 64-bit, launched from standard windows command shell. And I'm wondering how to explain to my young friend (a web designer by background) that the interpreter's CD
command does not require the %
.
It reminds me of DOS not needing a space after cd
. The REPL is not a shell, so why make this shortcut as if it were a shell? Why is a string name of a directory treated as a word when no such word has been set? Does it not make code needlessly ambiguous at a first glance?
(Think as if this is your FIRST programming language experience ... not as an old user of ls cd mv in unix shells.)
Even if a word is set, that word is ignored by cd unless a get-word is used ... example would be:
dir %tests
and
dir tests:
"complete" where cd tests
acts as if there is no word with get-word :tests
Note: Saphirion R3 has the following behavior : if I set a word to a dir name but in upper-case, the get-word moves me to that dir and shows it in that incorrect upper-case. But there is no dir with that name. I believe that the cd should have given an error. Surely as a matter of unicode and compliance with the linux-like world .. or is this only working on Windows ? Off I go to my Virtual Box with ubuntu and Syllable ...
You can have a look at the source of the
cd
function by writingThere you can find that for convenience, other datatypes are converted to file.
Rebol recognizes words by syntax allowing symbolic programming. It does not matter at all whether a word has been set or not to be recognized as a word.
Some operating systems (such as Windows) try to be case-insensitive, assuming that this is more convenient for humans.
Rebol string handling is also case-insensitive by default for the same reason.
That is essentially what happened but in a different manner. There is a
change-dir
function which insists on proper (file!) datatype, while thecd
function is a "convenience shortcut".