From 590441649198281427
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a1681fbe736bf77b
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-06-06 22:10:45 PST
Path: nntp.gmd.de!Germany.EU.net!EU.net!sun4nl!hacktic!motif.hacktic.nl!not-for-mail
From: rvloon@motif.hacktic.nl (Ronald van Loon)
Newsgroups: comp.std.c++
Subject: Re: Why do default arguments have to be at the end?
Date: 6 Jun 1994 22:49:10 +0200
Organization: Home of Motif++
Lines: 36
Message-ID: <2t0246$6e@motif.hacktic.nl>
References: <affrunti.770665780@orion.oac.uci.edu> <HAYDENS.94Jun3230156@wayback.atc.ll.mit.edu>
NNTP-Posting-Host: localhost.hacktic.nl

haydens@wayback.atc.ll.mit.edu (Hayden Schultz x3685 ) writes:

|">>>>> "Bob" == Bob Affrunti <affrunti@orion.oac.uci.edu> writes:

|"Bob> Why couldn't you have something like:

|"Bob> x.afunction( ,2,3,4 ); x.afrunction( ,2,,4 );

|"Well, for one thing there is an operator,(). So what would the above
|"syntax mean? Trouble for both the programmer and the compiler
|"writer. I think that anyone who writes code like afunction(a,(b,c),c)
|"should be taken out and shot, but that's valid C++ (and C) code, which
|"would be broken or very difficult to interpret.  Plus, it would be one
|"more break with C syntax for no real gain in functionality.

On the other hand, there is the `default' keyword - why not write
function-calls like `f(default,default,24)' ? That way, the programmer makes his
intention clear ("I only want to specify a different third argument to this
function") without having to resort to finding out what the current defaults
actually are.

It doesn't introduce ambiguity, because a single colon `:' is not a valid
thing to pass to a function, so one can distinguish between `default:' and
`default' without adding additional complexity to the language.

Of course, this is all very hypothetical if the committee isn't willing to
consider the possibility of defaults in other places, but it would be nice to
be able to specify a more natural order of arguments, instead of having to
rearrange them everytime because of `handy defaults'.

Just a thought.
-- 
Ronald van Loon        \   S-Mail: St. Janskerkhof 18  / Even when you're 
- Motif++ Maintainer    \          3811 HW Amersfoort /  on the right track
- Columnist C++ Report   \         The Netherlands   /   you'll get run over 
(rvloon@motif.hacktic.nl) \ Phone: +31 33 758 293   /    if you just sit there


