🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #824

named parameters

#824
From: Roland Schemers III
Date: Tue, 12 Feb 1991 17:36
51 lines
1869 bytes
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);

Then being able to say something like:

main()
{
     some_func(b:=10);
}

Thus by naming the parameter 'b' by using the ':=', you could then specify
the parameters in any order. VMS Pascal lets you do this and I think Ada
also has this. It would make calling functions like:

wind = new Window(width:=80,height:=24,x:=0,y:=0);

Much easier. It would also let you declare a function like:

some_func(int a=10, int b, int c=10);

and call it like:

some_func(b:=5);

Of course this brings up some problems with:

some_func(int a=10, int b);
some_func(int b);

But that could be flagged as ambigious.

It seems like the ':=' would be a good token to use for this syntax, although
people might get it confused with '='. There is also => which could also be 
used.

Comments?

Roland

-- 
Roland J. Schemers III                              Systems/Network Manager
schemers@vela.acs.oakland.edu (Ultrix)              Oakland University 
schemers@argo.acs.oakland.edu (VMS)                 Rochester, MI 48309-4401
You can tune a piano, but you can't tuna VMS!       (313)-370-4323
Technical Details
Message-ID: <5120@vela.acs.oakland.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!samsung!umich!vela!schemers

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!samsung!umich!vela!schemers
From: schemers@vela.acs.oakland.edu (Roland Schemers III)
Newsgroups: comp.std.c++
Subject: named parameters
Summary: flexible default parameters
Message-ID: <5120@vela.acs.oakland.edu>
Date: 12 Feb 91 17:36:04 GMT
Reply-To: schemers@vela.acs.oakland.edu (Roland Schemers III)
Organization: Oakland University, Rochester MI
Lines: 51