2

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 ...

  • Even if a word is set, that word is ignored by cd unless a get-word is used ... example would be dir %tests and tests: "complete" where cd tests acts as if there is no word with get-word :tests – G. Robert Shiplett Aug 05 '13 at 14:59
  • tested using reb core 278-3.1 on Win-7 64-bit launched from standard win cmd shell – G. Robert Shiplett Aug 05 '13 at 15:01
  • 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 ... – G. Robert Shiplett Aug 05 '13 at 15:09
  • Your question is clear and I agree with your concern, but I'm going to vote to close it. Because it's not really... answerable. StackOverflow questions need to have a sort of definable answer. Many reasonable and interesting discussion topics are closed because of their lack of an "answer", and I'm afraid this is a sort of design discussion. We can't *solve* it and it's hard to pick a *right answer*. But keep asking or perhaps answering questions and you can come chat all you want about things without answers. :-) – HostileFork says dont trust SE Aug 05 '13 at 15:56
  • This is subjective and argumentative, so I'll post it as a comment instead of an answer. "The REPL is not a shell, so why make this shortcut as if it were a shell?" Because the Rebol console is used by many Rebol users not only as a REPL, but indeed as a shell. This is especially true on Windows, where you will find many Rebol users argue that the Rebol console historically far surpassed the capabilities and usability of the Windows command-line. – earl Aug 05 '13 at 19:47

2 Answers2

3

You can have a look at the source of the cd function by writing

source cd

There you can find that for convenience, other datatypes are converted to file.

"Why is a string name of a dir treated as a word when no such word has been set?"

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.

"[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"

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.

"Did anyone ever suggest that chdir could have all convenience and quirks and that cd expect a file correctly named ?"

That is essentially what happened but in a different manner. There is a change-dir function which insists on proper (file!) datatype, while the cd function is a "convenience shortcut".

earl
  • 40,327
  • 6
  • 58
  • 59
Ladislav
  • 970
  • 4
  • 15
  • Yes, I can show him that ... but I have been showing him perverse aspects of Perl and some in Ruby and Python ( he still leans to Python or Ruby over Rebol or my personally preferred Curl + ObjectIcon ;-) My preference aside, I still urge Rebol for the group supporting it - as Object Icon is a group of 2 and Curl is now a group in Japanese and Korean who now seldom post in English. – G. Robert Shiplett Aug 05 '13 at 15:32
  • Did anyone ever suggest that chdir could have all convenience and quirks and that cd expect a file correctly named ? That adds a word with fluff/sugar, but leaves the simple unambiguously simple. Convenience for Perl folks was used in early Ruby ... and may even explain its existence, as it explains Objective-C, I believe. But now non-C programmers are learning Obj-C ;-) I accept that http:// is understood by read without a % sigil/prefix ... are there cases other than {comment } where quotes are optional for strings intended to be string values ? – G. Robert Shiplett Aug 05 '13 at 15:40
  • I use rebol scripts mostly to generate Curl markup ... but he will work with HTML5 ... I may prefer film camera, but I still suggest digital camera. Rebol has a great group ... that is real important for a newbie. Curl is not even on StackOverflow ... nor is ObjectIcon. I so try to set my preferences/bias aside. There is a YouTube on making just this effort at fair & balanced rather than "mine/ours is better". I also prefer Pharo Smalltalk, but would still recommend another version depending on considerations other than my preferences when it comes to Smalltalk implementations. – G. Robert Shiplett Aug 05 '13 at 15:47
  • Ditto for Prolog. I prefer Mercury, but swi-prolog has a great group and PDC has support. – G. Robert Shiplett Aug 05 '13 at 15:49
  • "My preference aside, I still urge Rebol for him because there is this group supporting it" In English "for" can be "because" in the non-causal sense of "for this reason". cheers – G. Robert Shiplett Aug 05 '13 at 15:55
  • "are there cases ... where quotes are optional for strings intended to be string values ?" - Rebol is a datatype-rich language. There is an ANY-STRING! typeset containing a lot of different string-like types. In R3 you can use HELP ANY-STRING! to get the list of the datatypes. Each of the datatypes has got its own syntax. Strings can be written either using double quotes or curly braces, e.g., files are preceded by %, tags are delimited by < and > characters, mails contain the @ character, URLs have the syntax like http://..., etc... – Ladislav Aug 05 '13 at 16:15
-1

You say "the REPL is not a shell". I totally agree. On a related note, I'm adamantly opposed to:

append [x y z] q

...appearing to crash the interpreter by invoking the shortcut for quit. It's an easy mistake to make. And I feel it's penny-wise and pound-foolish to do similar shortcuts that you have noticed in the core interpreter. Rebol is a literate, English-like language that reads clearly... and things like LS and CD do not belong in the core. They should be part of a shell dialect, if anything.

Should a dialect author should be able to treat words as strings even if the domain of the legal words doesn't map to the range of the legal strings? I think it should be allowed, but I agree it sets a poor precedent in the shipping executable.

  • allow a lot, but start clean and simple ;-) But do not add a pragma for ALLOW_QUIRKS ;-) ( Even the author of Traits for Smalltalk now has doubts about traits/mixins as they become "class" traits versus instance traits as a basic feature rather than an available addin.) – G. Robert Shiplett Aug 05 '13 at 15:52
  • This has nothing to do with the question about `cd` function. – rebolek Aug 07 '13 at 10:52
  • @rebolek The core of the question is about dismissing formalisms of the language for convenience at the REPL command line. So it's related to the "REPL is not a shell" point, less so to the point of whether CD takes words. But the motivations driving tolerance of abbreviation are similar... the laziness of not wanting to type the percent sign is just another aspect of the same warping of the language out of the box which winds up affecting you whether you run at a REPL or not. – HostileFork says dont trust SE Aug 09 '13 at 13:28