Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!agate!shelby!csli!zhu From: zhu@csli.Stanford.EDU (Lei Zhu) Newsgroups: comp.lang.c++ Subject: Re: Named arguments? Keywords: lisp keyword arguments Message-ID: <10102@csli.Stanford.EDU> Date: 16 Aug 89 05:40:24 GMT References: <612@windy.dsir.govt.nz> <2179@uw-entropy.ms.washington.edu>Sender: zhu@csli.Stanford.EDU (Lei Zhu) Reply-To: zhu@csli.stanford.edu (Lei Zhu) Organization: Center for the Study of Language and Information, Stanford U. Lines: 31 In article neal@cs.rochester.edu (Neal Gafter) writes: >I have noot seen a good syntax proposed for named arguments, so let me >make a specific proposal that is upwardly-compatible with C++, seems >natural (at least to me), and introduces no ambiguities: > >extern int distance(int x, int y, int z, float scale = 1.0); > >main() >{ > extern int x1, y1, z1; > extern float scale; > > int result = distance(scale: scale1, x: x1, y: y1, z: z1); >} >Opinions? That reminds me of keyword arguments in lisp, even the syntax is similar. Your example would be like (distance :scale scale1 :x x1 :y y1 :z z1) in lisp. I find this feature to be especially useful when there isn't a natural orderings of parameters and/or there are lots of parameters. Anyway, I think it's a good idea and your syntax is about as good as I can of. Just my two cents, --Lei