Xref: utzoo comp.lang.c++:4122 gnu.g++:299 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!apple!usc!orion.cf.uci.edu!uci-ics!schmidt@glacier.ics.uci.edu From: schmidt@glacier.ics.uci.edu (Doug Schmidt) Newsgroups: comp.lang.c++,gnu.g++ Subject: Re: Default argument values Message-ID: <20077@paris.ics.uci.edu> Date: 25 Jul 89 18:09:14 GMT References: <43253@bbn.COM> Sender: news@paris.ics.uci.edu Reply-To: schmidt@glacier.ics.uci.edu (Doug Schmidt) Followup-To: comp.lang.c++ Distribution: comp Organization: University of California, Irvine - Dept of ICS Lines: 36 In-reply-to: lpringle@bbn.com (Lewis G. Pringle) In article <43253@bbn.COM>, lpringle@bbn (Lewis G. Pringle) writes: >In article fox@cs.cs.columbia.edu (David Fox) writes: >>The way to do this is to allow caller to name the parameters >>the way Ada does: foo(parm1 = a, parm3 = b, parm2 = c). > >I second the emotion, but it may be harder than it looks. What your are >describing (I think) are called keyword parameters. The difficulty, >is that they impose even more ambiguity into the language. Default params, >together with overloading, and conversion operators, already add >lots ambiguity - keyword paramers would make things even worse. There's also another problem. Allowing ``named parameters,'' a la Ada, weakens information hiding, since formal parameter names are now visible *outside* their original scope! For example, consider the effect of changing a formal parameter name in C or C++. All you need to modify are the uses of this formal parameter name *inside* the enclosing function. This change is trivial to perform using an interactive query-replace editor feature. On the other hand, in a language that allows named parameters you need to hunt down all instances of the formal parameter names occurring in all *calls* to the function. These calls are potentially spread throughout many source files, and it becomes difficult to change the names in an automated fashion, for the reasons alluded to above. IMHO, named parameters are another Ada (mis)feature that adds gratuitous complexity to the compiler and programmer without providing much value-added benefit. Doug -- Master Swordsman speak of humility; | schmidt@ics.uci.edu (ARPA) Philosophers speak of truth; | office: (714) 856-4034 Saints and wisemen speak of the Tao of no doubt; The moon, sun, and sea speaks for itself. -- Hiroshi Hamada