Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-02-21 10:37:34


----- Original Message -----
From: "Herb Sutter" <hsutter_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, February 21, 2002 12:05 PM
Subject: RE: [boost] More on auto

>
> > I feel impelled to INSIST that non-expressive type deductions should be
> > abandoned. We need to figure out how to make it more expressive.
>
> > I can think of syntactic addition to auto that would at least give it a
> > little expressiveness.
>
> > int can_you_guess_what_is_this_doing()
> > {
> > auto T a = foo();
>
> If we adopt both auto and strict typeof, we can already do that:
>
> auto a = foo();
> typedef typeof(a) T;
>
> Herb
>
Right.

But why wouldn't we want auto to 'require' a type name?
Would it be more complex to implement?
Would it be too difficult to use?
Would the rules for auto-typed variables interaction be too complex to
design?

I don't think so for any of the above, though I see that it would give a lot
of expressiveness to our code.

The same arguments that would stand for a 'bare' auto would stand for
typeless template arguments, as in:

template<> foo (a,b,c,d,e,f)
{
  if ( a > b )
   g = c - d * 2 + f * foo(f,e,d,c,b,a);
  return g ;
}

There no difference between the above and a function with all local
variables being 'bare' autos with respect to expressiveness

Think about Peter's interpretation of the semantic of 'auto':

> template<class X> void do_something_with_x(X x);
> do_something_with_x(expr);

Inside "do_something_with_x", x is of type X.
This is as important inside the function, as it is important in the scope of
a local auto variable.

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


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