Topic: Keyword Parameters


Author: jpsa@arc.ug.eds.com
Date: 10 May 93 12:35:30 GMT
Raw View
Sorry - lost the title line in previous posting.  For "<none>" read
"Re: Keyword Parameters".

John Aldridge




Author: dano@dogfish.boeing.com (Dan Olson)
Date: 4 May 93 17:01:35 GMT
Raw View
Why are keyword function parameters not a part of C++ (besides being
overlooked)?  Coming from a lisp background, I find them to be very
useful, especially for hairy constructors with > 4 arguments.  Even
Ada has keyword parameters.

Would they be much work to add?  Probably to the evolving standard,
but just adding them to g++ (which tends to go beyond ansi) might be a
good start.

Example:
  void func(int a=0, int b=0, int c=0);

could be called as:
  func(c: 5, a: 3);

(This isn't a suggested syntax for keywords, just a demonstration.
 And, of course, paremeters w/o default values can't be set with a
 keyword specification.)
--
    UUCP: ..!uunet!bcstec!plato!dogfish!dano
Internet:  dano@dogfish.ds.boeing.com




Author: joe@crl.ucsd.edu (Joe)
Date: 5 May 1993 17:19:15 GMT
Raw View
>Why are keyword function parameters not a part of C++

>  void func(int a=0, int b=0, int c=0);
>  could be called as:
>  func(c: 5, a: 3);

Hmm, interesting. So, if I understand you correctly, C-front
might mangle your function call to:

__1_func_int_int_int ( 3, 0, 5);  //  ???

I see a minor prolem. func() could be declared as:
void func (int,int,int); The delcared variable names are optional,
and furthermore, they are not required to match up with the
actual function definition, even if they are used. Also, some
name space ambiguity might occur (think about it).

I like the syntax, though; and this nicely solves the problem
of ambiguous defaults. Not that I appreciate you using the "L"
word in the same sentence with C++ ;-)

Joe.

--
/////////////////////////////////////////////////////////////////
// Joseph Kraska        jkraska@kirin.bbn.com       BBN LABS   //
// "We write software that will almost do almost everything."  //
/////////////////////////////////////////////////////////////////




Author: grumpy@cbnewse.cb.att.com (Paul J Lucas)
Date: Sat, 8 May 1993 01:51:10 GMT
Raw View