Topic: Type checking
Author: deutronium@web.de ("cody")
Date: Tue, 8 Apr 2003 18:10:21 +0000 (UTC) Raw View
> C++ has new casts. These are static, dynamic and reinterpret. They are
> much safer than the old C casts.
the problem now is, nobody uses them, which makes them useless. the language
isn't safer because there are additional cast-types. it would only be safer
if the old casts would be forbidden by the language.
i've never understood why they invented thesenew casts.
--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu
[noncommercial and no fucking ads]
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: ron@sensor.com ("Ron Natalie")
Date: Tue, 8 Apr 2003 19:08:38 +0000 (UTC) Raw View
""cody"" <deutronium@web.de> wrote in message news:z4Aka.9$Zt6.2091@news.ecrc.de...
> > C++ has new casts. These are static, dynamic and reinterpret. They are
> > much safer than the old C casts.
>
> the problem now is, nobody uses them,
That's not true. Bad programmers don't use them.
> which makes them useless. the language
> isn't safer because there are additional cast-types.
C++ doesn't exist to forbid bad programming practices, but to allow good ones.
> it would only be safer
> if the old casts would be forbidden by the language.
Untrue, if you avoid using the old-style cast in preference to the new ones, then it does
become safer. For example,
The casts each have a limitted scope. This keeps you from inadvertantly drastically
changing the type or constness of an object. The old-style cast will happily degenerate
to a reinterpret_cast.
> i've never understood why they invented thesenew casts.
Furthermore, the casts do diffrent things in differenent circumstances. While
the old casts are a conglomeration of static, const, and reintrpret casts, dynamic
cast behavior is not found in there.
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: hyrosen@mail.com (Hyman Rosen)
Date: Tue, 8 Apr 2003 19:08:40 +0000 (UTC) Raw View
cody wrote:
> the problem now is, nobody uses them
We use them in all code we write in my company.
I don't know why you think that they wouldn't be used,
since they make for better code. Perhaps you have just
encountered poorly educated programmers? I know from my
experience in interviewing potential hires that very few
people who claim to be good in C++ are even minimally
competent.
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: wolof@freemail.hu ("White Wolf")
Date: Tue, 8 Apr 2003 20:31:31 +0000 (UTC) Raw View
""Ron Natalie"" wrote:
[SNIP]
> Untrue, if you avoid using the old-style cast in preference to the new
ones, then it does
> become safer. For example,
> The casts each have a limitted scope. This keeps you from
inadvertantly drastically
> changing the type or constness of an object. The old-style cast will
happily degenerate
> to a reinterpret_cast.
[SNIP]
IIRC even worse. They can degenerate into something accessing a
non-accesible base class. :-(
WW
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: allan_w@my-dejanews.com (Allan W)
Date: Wed, 9 Apr 2003 02:52:44 +0000 (UTC) Raw View
In the year 967 B.C.E., noah@ark.com (Noah) wrote in message
12!34@oxen!12@primates!central.ark.net :
> The problem is, nobody uses [third-generation languages], which
> makes them useless. Computer programming isn't easier because there
> are new computer languages. It would only be easier if we didn't
> let them use good ol' assembly language anymore.
>
> Don't know why those whippersnapper invented these new languages
> anyway. What could be more natural than "ld r2; mu r1; st r3.b"? It
> was good enough for my daddy; he wrote the entire AOS (Arc
> Operating System) in 2000 lines of assembly language, and debugged
> it with live animals! Only had one fatality, my third wife, but
> the other nine survived, so no big loss...
>
> Almost makes me wish I had room to drag the old man with me!
And then a few thousand years went by, and then
deutronium@web.de ("cody") wrote
> the problem now is, nobody uses [new-style casts], which makes
> them useless. the language isn't safer because there are additional
> cast-types. it would only be safer if the old casts would be
> forbidden by the language.
>
> i've never understood why they invented thesenew casts.
Coincidence? Probably... but it's still a bit spooky for my taste.
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: deutronium@web.de ("cody")
Date: Thu, 10 Apr 2003 05:47:35 +0000 (UTC) Raw View
> IIRC even worse. They can degenerate into something accessing a
> non-accesible base class. :-(
what is a non-accesssible base-class???
--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu
[noncommercial and no fucking ads]
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: deutronium@web.de ("cody")
Date: Thu, 10 Apr 2003 19:12:35 +0000 (UTC) Raw View
hehe :-)
--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu
[noncommercial and no fucking ads]
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: kanze@gabi-soft.de (James Kanze)
Date: Thu, 10 Apr 2003 19:12:59 +0000 (UTC) Raw View
allan_w@my-dejanews.com (Allan W) wrote in message
news:<7f2735a5.0304081404.605b5a81@posting.google.com>...
> In the year 967 B.C.E., noah@ark.com (Noah) wrote in message
> 12!34@oxen!12@primates!central.ark.net :
> > The problem is, nobody uses [third-generation languages], which
> > makes them useless. Computer programming isn't easier because there
> > are new computer languages. It would only be easier if we didn't let
> > them use good ol' assembly language anymore.
> > Don't know why those whippersnapper invented these new languages
> > anyway. What could be more natural than "ld r2; mu r1; st r3.b"? It
> > was good enough for my daddy; he wrote the entire AOS (Arc Operating
> > System) in 2000 lines of assembly language, and debugged it with
> > live animals! Only had one fatality, my third wife, but the other
> > nine survived, so no big loss...
> > Almost makes me wish I had room to drag the old man with me!
> And then a few thousand years went by, and then
> deutronium@web.de ("cody") wrote
> > the problem now is, nobody uses [new-style casts], which makes them
> > useless. the language isn't safer because there are additional
> > cast-types. it would only be safer if the old casts would be
> > forbidden by the language.
> > i've never understood why they invented thesenew casts.
> Coincidence? Probably... but it's still a bit spooky for my taste.
Brillant. I especially liked the touch of using bang-addresses in the
lead-in to the first quote.
As to the claim that "nobody uses ...", g++ has an option to warn if an
old stype cast is used. I rather imagine that they didn't introduce
this option on just a whim; that people actually wanted it and are using
it.
--
James Kanze GABI Software mailto:kanze@gabi-soft.fr
Conseils en informatique orient e objet/
Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France, T l. : +33 (0)1 30 23 45 16
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: sjbright3@attbi.com ("codehammer")
Date: Mon, 31 Mar 2003 04:23:26 +0000 (UTC) Raw View
This is a multi-part message in MIME format.
------=_NextPart_000_000A_01C2F5D9.FB1E4AD0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
How does C++ have stronger type checking than C?
Is there an example of a variable passed to a function in C that causes
an error, where the same error would be caught due to C++ type checking?
Thank You
------=_NextPart_000_000A_01C2F5D9.FB1E4AD0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1141" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY style=3D"COLOR: #000000; FONT-FAMILY: Arial" bgColor=3D#ffffff>
<DIV><FONT size=3D2>How does C++ have stronger type checking than =
C?</FONT></DIV>
<DIV><FONT size=3D2>Is there an example of a variable passed to a =
function in C=20
that causes</FONT></DIV>
<DIV><FONT size=3D2>an error, where the same error would be caught due =
to C++ type=20
checking?</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Thank You</FONT></DIV>
<DIV><FONT size=3D2><BR></FONT></DIV></BODY></HTML>
------=_NextPart_000_000A_01C2F5D9.FB1E4AD0--
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: francis.glassborow@ntlworld.com (Francis Glassborow)
Date: Mon, 31 Mar 2003 15:09:41 +0000 (UTC) Raw View
In article <bqjha.12770$Zo.5747@sccrnsc03>, codehammer
<sjbright3@attbi.com> writes
>How does C++ have stronger type checking than C?
>Is there an example of a variable passed to a function in C that causes
>an error, where the same error would be caught due to C++ type
>checking?
For example there are no implicit conversions from void* in C++
--
ACCU Spring Conference 2003 April 2-5
The Conference you cannot afford to miss
Check the details: http://www.accuconference.co.uk/
Francis Glassborow ACCU
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: ryan.winter@optusnet.com.au (Ryan Winter)
Date: Mon, 31 Mar 2003 18:07:35 +0000 (UTC) Raw View
Hi codehammer,
C++ has new casts. These are static, dynamic and reinterpret. They are
much safer than the old C casts.
Ryan Winter
codehammer wrote:
> How does C++ have stronger type checking than C?
> Is there an example of a variable passed to a function in C that causes
> an error, where the same error would be caught due to C++ type checking?
>
> Thank You
>
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: wolof@freemail.hu ("White Wolf")
Date: Mon, 31 Mar 2003 19:00:16 +0000 (UTC) Raw View
""codehammer"" wrote:
> How does C++ have stronger type checking than C?
> Is there an example of a variable passed to a function in C that
causes
> an error, where the same error would be caught due to C++ type
checking?
For example in C++ you must declare a function before you can use it.
In C (IIRC also in C99) you can still just tell: there will be such a
function, without providing the exact types.
WW
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: ron@sensor.com ("Ron Natalie")
Date: Mon, 31 Mar 2003 19:01:09 +0000 (UTC) Raw View
"Ryan Winter" <ryan.winter@optusnet.com.au> wrote in message news:3e88327f$0$11661$afc38c87@news.optusnet.com.au...
> Hi codehammer,
>
> C++ has new casts. These are static, dynamic and reinterpret. They are
> much safer than the old C casts.
>
....and const.
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: hyrosen@mail.com (Hyman Rosen)
Date: Mon, 31 Mar 2003 19:01:20 +0000 (UTC) Raw View
codehammer wrote:
> How does C++ have stronger type checking than C?
C allows a function to be called without that function
having been declared. It further allows a function name
to be declared without specifying the types of its
parameters. Therefore, in C it is possible to call a
functions with parameters whose types are unexpected by
that function.
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]