Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!ithaca!garry From: garry@ithaca.uucp (Garry Wiegand) Newsgroups: comp.std.c++ Subject: Re: named parameters Message-ID: <1991Feb15.204108.122@ithaca.uucp> Date: 15 Feb 91 20:41:08 GMT Organization: Ithaca Software Lines: 49 In article <5120@vela.acs.oakland.edu> schemers@vela.acs.oakland.edu (Roland Schemers III) writes: >I was wondering if the concept of named parameters has ever came up. >Right now you can declare a function like so: > >some_func(int a, int b=0); > >But since you can only have default values listed at the end this makes for >a real pain. Has anyone proposed the following: > >some_func(int a=10, int b=0); >... >Comments? Roland - It would be lovely. When I read through the ARM I red-flagged the some_func(int a, int b=0) syntax as a stylistic Bad Idea - it's OK for one (or maybe two) optional arguments, but for multiple optional arguments it degenerates into something that is very hard to explain to a "normal human". Ie, if you have a function with parameters (a,b,c,d) it's purely good luck if the argument "d" that would logically be mentioned last also happens to be the argument that would naturally be omitted first, it's unusual that every single time you might want to omit "c" you will already have decided to omit "d", it's improbable that every single time you might want to omit "b" you will already have decided to omit "c" and "d", and it's approaching absurd (except in specially-constructed cases) that every single time you might want to omit "a" you will already have decided to omit "b", "c" and "d". So it looks to me like the ARM's optional-argument style is brain-dead, and just clutters up the language to no good purpose. Real optional arguments, such as you propose, would be very interesting, but you will probably run into the argument that the ":=" pseudo-operator "doesn't look like C". Garry Wiegand --- Ithaca Software, Alameda, California ...!uunet!ithaca!garry, garry%ithaca.uucp@uunet.uu.net