[Posted to the INFO-VAX mailing list] Date: Wed, 13 Oct 93 08:08:49 EDT From: Jerry Leichter I find it remarkable that even someone who loves VMS would defend the primitive state of its control structures. Rumour has it that the person who inherited DCL from Dave Cutler - who wrote the first cut, producing a mass of complex spaghetti code that's been the bane of maintainers ever since - designed and even implemented modern control structures. Dave Cutler, still there running the show, insisted that she take them out. The man has very definite opinions about certain things. He doesn't care what the world thinks, it's his way or not at all. Many years ago, I used BASIC PLUS on RSTS (V5B, for those who remember). I found it too difficult to work with all those line numbers, and developed a pre-processor (in TECO) which let me use line labels. Later, when I moved to VMS, I had the same reaction to DCL, and responded in the same way: I wrote a pre-processor, in TECO, which provided things like IF-THEN-ELSE, WHILE loops, and subroutines. I called the result RCL (for Reasonable Command Language) and actually distributed it within DEC with the deliberately inflammatory abstract that it was dedicated to the proposition that DCL made a perfectly good object language. The oldest documentation I can quickly find on RCL dates back to 1983, and it was then at version 1.4. (Internal references in the documentation indicate that it dates back to the beginning of 1982. I think that would be VMS V2.4 or so.) I use it to this day, if for nothing else than to strip out comments. Over the intervening 10 years, DCL has taken quite a few steps toward the modern world. GOSUB subroutine calls, CALL, block if-then-else: It's not quite as bad as it once was! However, when it comes to DCL, people display long memories and great inertia. All the command files still being written with "''FOO'" where just FOO would do are a prime example: People learn from old, bad code that they've seen, not from the manuals. Actually, I'm guilty of this myself: I don't think I've ever actually written any DCL using GOSUB or CALL, and I've never really gotten used to SET SYMBOL. What DCL still lacks is loops. Yes, you can write them with GOTO's; but you shouldn't have to. Something like a CASE statement would also be nice, but it's not nearly as important: It doesn't come up all that often, and there are just too many variations. (Yes, I know about the case statements in the Unix shells. Before you take them as examples, make sure you understand their contorted syntax.) There's really no excuse for the lack of at least a WHILE loop. A shell-style FOR loop isn't nearly as important; most of the things that a shell programmer would do with a FOR loop are as naturally done on VMS using lexicals like F$ELEMENT and F$SEARCH. At least they are natural as soon as you have a natural looping construct. (Of course, it would have really helped if F$SEARCH hadn't been given so stupid a way of dealing with filespecs with no wild-cards in them. Sigh.) Unix shells contain tons of special-case features. For example, where in VMS you might write: $ if F$TYPE(foo) .eqs. "" then foo = "default-value" in a shell there's a way to refer to "foo, or if that's not defined, then default-value" - something like $(foo=default-value), but who can remember. This is just one example of shell shorthand that, taken all together, makes many shell scripts examples of write-only code. Frankly, I can't say I've ever missed that sort of stuff. If DCL had decent support for loops, I'd be pretty happy with it as a programming language. (In fact, almost* the only thing in RCL that isn't yet in DCL is a WHILE loop and a very simple REPEAT loop, which increments a counter each time around until it reaches a specified limit. Of course, RCL subroutines can nest to arbitrary depths.... :-) ) If DCL were also to add a way to call subroutines in a functional context, so that I could do something like: $ if F$MY_SUBR(args) then ... (which today would be written as: $ CALL MY_SUBR args $ if RESULT then ... where MY_SUBR sets RESULT) life would be even nicer. (Yes, modern Unix shells can do this kind of thing. Sigh.) -- Jerry *For those who wonder: RCL also supports the command sequence: $ FILE spec $ EOF which is like $ CREATE spec $ DECK $ EOD except that DCL symbol substitution is carried out within .