RWK%SCH-GODZILLA@MIT-MC.ARPA (04/16/84)
From: "Robert W. Kerns" <RWK%SCH-GODZILLA@MIT-MC.ARPA> Date: 16 Apr 84 21:17:26-EST (Mon) From: ihnp4!drutx!houxe!hogpc!houti!ariel!vax135!floyd!clyde! From: watmath!utzoo!utcsrgv!peterr @ Ucb-Vax Hippity hippity hop. Subject: Time for keyword parameters for prog. lang's (Lots of assemblers and things have always supported keyword arguments, especially in macros for some reason. VMS makes big use of it, both in languages and in commands). Still, the added typing, with increased chance of typos, *would* be a nuisance. Fortunately, the technology is with us to avoid this extra typing. A language-based editor can easily maintain a database of procedure parameters and present a procedure call template on demand. For example, if one types Lookup( then it could complete the statement, resulting in Lookup(name: _____, symIndex: ______) and position the cursor at the first field (type and parameter kind (pass by value, value-result, reference, etc.) information could also be presented). If anyone knows of a programming environment that supports such a scheme, I'd be grateful to hear about it. Ada and, I believe, Mesa support keyword parameters, but I don't know if the APSE or Cedar environments have procedure call templates... does anyone out there know? Zmacs (the editor on the Lisp machine), together with Zetalisp or Common Lisp, provide you with aids along a somewhat parallel line. While you're typing in the arguments to a function, you can type Control-Shift-A, and the argument list for the function will be displayed at the bottom of your screen. You still have to type in the keywords (or positional arguments), but you don't have to remember how to spell them. It even tells you the default values, and if multiple return values are declared, it tells you about those as well. But this doesn't address the issue of saving typing. I have had some experience with template-based tools, in an editing package I put together in EMACS for an experimental lisp-based languaged that was used in Macsyma at one time. I found there is a fundamental incompatibility between keyword arguments and templates. One of the most important points to keyword arguments that they are amorphous. You don't have to include them all, and you don't have to include them in any specific order. I found I had to do nearly as much work to DELETE extraneous keywords from the list as I would to type them in by hand. The big advantage of templates, either in positional or keyword syntaxes, is in the prompting they provide. Zmacs provides this quite handily. But it would be fairly easy, now that I think of it, to provide COMPLETION of keywords in Zmacs. I think this would come close to providing the best of both worlds.
Masinter.pa@Xerox.ARPA (04/16/84)
In reply to the message from Peter Rowley Peter, The history of programming language design is one going back and forth trying to achieve incompatible goals. In this case, the goals are that programs should be both easy to read and easy to write; easy for novices and people unfamiliar with the program they are working on, but also easy for experts and those intimately familiar with the program. Keyword parameters are nice if you are reading a program with calls to subroutines you don't recognize, or if you are writing in a language where you remember the procedure names but not the argument order. Keyword paramters areso nice because they tend to make programs more verbose, and require you to type a lot of stuff that would otherwise be irrelevant. Making them optional doesn't help much, because the keywords tend to help the novice and get in the way of the expert, both of whom might be working on the same program. As you mentioned, a language-based editor can help quite a bit. For example, Interlisp has a command, "?=", which means 'show me the argument names'), in a variety of contexts. If you are typing something, it will show you the argument names for the function you are in, including the correspondence between formals and any actuals you've already typed. If you are reading a program with the editor and want to know what arguments are being passed to what, you can find out again using the "?=" command. This is different than your suggestion, because the names don't actually appear in the program; it is just that the environment makes them visible when you want to see them. Similar facilities could exist in other interactive programming environments, as long as you were able to separate the 'text' of the program some from its structure and the system was willing to parse what you were typing as you typed it. One could possibly extend this in interesting ways, e.g., allow the programmer to type procedure calls in either way (keywords or not) and display them either way depending on some modes in the editor. The key is to separate out the 'program' from the characters that represent it; given the same program, you can look at it in a variety of different ways, none of which is necessarily canonical.