Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-02-18 15:41:21


At 01:19 PM 2/18/2002, Jeremy Siek wrote:

>On Mon, 18 Feb 2002, Beman Dawes wrote:
> >As posted earlier, there's a difficulty in trying to shoehorn named
> >parameters into the current framework, because parameters names
currently
> >don't mean anything, only position does. Take for example:
> >
> >template <typename A = char, typename B = int> class foo;
> >...
> >template <typename B = char, typename A = int> class foo;
> >
> >foo<B=int> // what does this mean?
>
> Can't you just say "first seen?" as the answer to the question?
>
> An implementation might also (as QOI) warn if additional declarations
> rename or reorder the parameters.
>
>That is certainly an option. The disadvantages I see are 1) it is
fragile:
>a change in the order of the declarations would change the meaning of the
>program (when normally that isn't the case),

That sounds like a killer argument.

> and 2) compilers would start
>emitting warnings about code that currently is perfectly good C++.

Personally I'd consider such code to be really questionable anyhow, but I
suppose somewhere it has been done a great deal. It would have to be
possible to turn off the warning.

Anyhow, because of (1), it sounds like some different syntax is
required. ":=" or something. Thus no existing code can be broken, because
there is no existing code which uses the new syntax. Downside is libraries
have to explicitly enable named parameters. Gives library designers
control, rather than users. But it would extend the notation to cover
function arguments ("=" is a non-starter for function arguments because it
couldn't be distinguished from operator=). Distinct syntax might make the
resulting code a bit easier to read. Excessive symbol overloading can be a
serious source of reader confusion.

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk