Topic: Proposal for type-safe built-in arrays (lo
Author: chris@alofi.etca.fr (Christian Millour)
Date: 1997/02/25 Raw View
In article <199702170220.SAA05617@taumet.eng.sun.com>,
Stephen.Clamage@eng.sun.com (Steve Clamage) writes:
|> A detailed, extensive, and really very nice proposal to solve the
|> type safety problem of C-style arrays was presented very early in the
|> C++ standardization process.
|>
|> A lot of people liked the proposal, but as you note, it breaks
|> compatibility. Invalidating nearly all existing C and C++ programs,
|> int main(int argc, char** argv) { ... }
|> vs
|> int main(int argc, char* argv[]) { ... }
|> to pick a simple example, was not considered an attractive idea.
|>
|> In the end, it was decided to leave C-style arrays alone. A complete
|> fix is too incompatible, and a partial fix leading to partial
|> incompatibility is pointless.
compiler options, like "use-old-for-scope", are IMHO the right tool to
deal with compatibility issues. Couldn't it have been appropriate here ?
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Stephen.Clamage@eng.sun.com (Steve Clamage)
Date: 1997/02/17 Raw View
In article 4DA4@pratique.fr, Valentin Bonnard <bonnardv@pratique.fr> writes:
>
>There is still a hole in the C++ type system (inherited from C,
>as usual), that there is no distinction betwen the type of:
>(1) a polymorphic pointer and
>(2) a pointer to an array. ...
>
>I suggest that two types are needed to express (1) and (2),
>a syntax to express them, and a clear semantic distinction
>betwen (1) and (2).
>
>void foo1 (Base*); // means (1)
>void foo2 (Base[]); // means (2)
A detailed, extensive, and really very nice proposal to solve the
type safety problem of C-style arrays was presented very early in the
C++ standardization process.
A lot of people liked the proposal, but as you note, it breaks
compatibility. Invalidating nearly all existing C and C++ programs,
int main(int argc, char** argv) { ... }
vs
int main(int argc, char* argv[]) { ... }
to pick a simple example, was not considered an attractive idea.
In the end, it was decided to leave C-style arrays alone. A complete
fix is too incompatible, and a partial fix leading to partial
incompatibility is pointless.
Programmers should learn to use C++ array classes and templates instead
of C-style arrays. The standard library contains a variety of them,
for example.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]