Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utcsrgv.UUCP Path: utzoo!utcsrgv!peterr From: peterr@utcsrgv.UUCP (Peter Rowley) Newsgroups: net.works Subject: Time for keyword parameters for prog. lang's Message-ID: <3783@utcsrgv.UUCP> Date: Mon, 9-Apr-84 00:17:26 EST Article-I.D.: utcsrgv.3783 Posted: Mon Apr 9 00:17:26 1984 Date-Received: Mon, 9-Apr-84 01:27:42 EST Organization: CSRG, University of Toronto Lines: 51 It is finally generally accepted that positional parameters in command languages are to be avoided. The difference between UNIX(tm Bell Labs) and JCL or CDC NOS command syntax is testament to this. It is time to apply this lesson to programming languages. The general rule is that positional parameters should be replaced by keyword parameters. For example, Lookup("frodo", i) could be written as Lookup(name:"frodo", symIndex: i) or Lookup(symIndex: i, name: "frodo"). The keyword is exactly the formal parameter of the procedure-- no change in procedure declaration syntax is needed. Exceptions to the general rule could be provided for situations in which the role of the parameter(s) is obvious. For example, sqrt(a) would suffice. This scheme has important advantages. When one is writing code, it is easier to remember mnemonic keywords than arbitrary parameter positions. When reading code (and remember that 80% of the programming task is maintenance), it is even more important-- the keywords provide useful information about the input and output of the procedure, right where it is needed in the program text. This latter advantage is even more important for programming languages than command languages, as program code is read so much more. The disadvantage is that one has to type more to specify a procedure call. The redundancy of having to specify the keyword verifies that one knows the role of each parameter, however. 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). Another advantage to the scheme is that it allows simple omission of parameters, letting them assume default values. It is also easy to retrofit to existing languages, as one can easily write a processor to convert a program written in positional notation to one using the keyword notation. 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? peter rowley, University of Toronto Department of C.S., Ontario Canada M5S 1A4 UUCP {linus ihnp4 allegra floyd utzoo cornell decwrl uw-beaver}!utcsrgv!peterr CSNet peterr@toronto