Thread View: comp.std.c++
1 messages
1 total messages
Started by Roland Schemers III
Tue, 12 Feb 1991 17:36
named parameters
Author: Roland Schemers III
Date: Tue, 12 Feb 1991 17:36
Date: Tue, 12 Feb 1991 17:36
51 lines
1869 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads