Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #9378

Re: which of these 3 casts would you prefer?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: which of these 3 casts would you prefer?
Date Sun, 28 Aug 2011 10:47:44 +1200
Lines 56
Message-ID <9btaggFopsU4@mid.individual.net> (permalink)
References <j36gjq$6ee$1@gregory.bnet.hr> <op.v0s9312a42vrml@debian> <j3848g$44o$1@gregory.bnet.hr> <j3b6me$eof$1@news.albasani.net> <4e5939a5$0$3061$7b1e8fa0@news.nbl.fi> <j3bobh$kkf$1@news.albasani.net> <9bt839FopsU3@mid.individual.net> <j3brak$q7n$1@news.albasani.net>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net foRcXWSA95XoXZNtklVHdAh25IU+8AwAAc1HP3Caizpkly9lB5
Cancel-Lock sha1:4kzQGzlGP3hAujZFK/SUXucvy4U=
User-Agent Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4
In-Reply-To <j3brak$q7n$1@news.albasani.net>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:9378

Show key headers only | View raw


On 08/28/11 10:27 AM, BGB wrote:
> On 8/27/2011 3:06 PM, Ian Collins wrote:
>> On 08/28/11 09:37 AM, BGB wrote:
>>> On 8/27/2011 11:38 AM, Juha Nieminen wrote:
>>>>
>>>> The major problem in C is not the lack of dynamic binding. It's the
>>>> lack of RAII and templates. (And, to some extent, exceptions.)
>>>
>>> RAII normally only really deals with cases which can be dealt with
>>> manually though (apart from exceptions, which also don't exist in C, and
>>> things like longjmp are rarely used).
>>
>> The beauty of RAII is you don't have to implement it manually! This
>> eliminates a whole class of common programming errors.
>
> yep, but this is still more of a convenience feature, rather than a
> fundamental limitation.

It is a fundamental feature in the sense that it allows automated 
resource management.  Automated resource management leads to safer, 
cleaner, code.  It also removes the single, all be it feeble, excuse for 
using goto which has to be a good thing!

> it is not really too much different from using OpenGL and remembering to
> always have a matching "glEnd();" for every "glBegin();", or a
> "glPopMatrix();" for every "glPushMatrix();".
>
> if one messes up on these sorts of things in OpenGL, things will turn
> ugly...

Exactly.  With RAII, you eliminate the chance of things turning ugly.

>>> also, several other major languages, such as Java and C#, also lack RAII
>>> (with exceptions, this behavior is handled by the use of a "finally"
>>> clause).
>>
>> Yet another manual kludge..
>>
>
> well, it can be seen this way...

How else can you see it?  Missing a finally (or leaving a release out of 
one) is just as bad as forgetting a free in C.

> I am not claiming here that C is perfect or equally programmer-friendly
> to C++ or anything, but rather there may be other bigger concerns, and
> that conveniences are not "essential".

No language feature is "essential".  We can program in machine code if 
we choose.  Most of us don't write machine code these days (although I 
have to admit I did enjoy it back in the day!) because we have 
programming languages that directly support safer and more advanced 
idioms.

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

which of these 3 casts would you prefer? "A" <a@a.a> - 2011-08-25 23:58 +0200
  Re: which of these 3 casts would you prefer? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2011-08-25 16:19 -0700
  Re: which of these 3 casts would you prefer? Robert Wessel <robertwessel2@yahoo.com> - 2011-08-25 18:59 -0500
  Re: which of these 3 casts would you prefer? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-26 08:02 +0200
  Re: which of these 3 casts would you prefer? "Duga Chernobyl" <duga_c3@gmx.com> - 2011-08-26 10:05 +0200
    Re: which of these 3 casts would you prefer? "A" <a@a.a> - 2011-08-26 14:40 +0200
      Re: which of these 3 casts would you prefer? Leigh Johnston <leigh@i42.co.uk> - 2011-08-26 13:59 +0100
      Re: which of these 3 casts would you prefer? "Duga Chernobyl" <duga_c3@gmx.com> - 2011-08-26 15:19 +0200
        Re: which of these 3 casts would you prefer? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-26 21:27 +0000
          Re: which of these 3 casts would you prefer? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-27 01:28 +0200
          Re: which of these 3 casts would you prefer? "Duga Chernobyl" <duga_c3@gmx.com> - 2011-08-27 10:23 +0200
            Re: which of these 3 casts would you prefer? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-27 12:10 +0000
          Re: which of these 3 casts would you prefer? RaZiel <raziel_206_@hotmail.com> - 2011-08-27 21:55 +0200
          Re: which of these 3 casts would you prefer? Miles Bader <miles@gnu.org> - 2011-09-01 08:03 +0900
            Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-08-31 23:11 -0700
            Re: which of these 3 casts would you prefer? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-01 19:34 +0000
              Re: which of these 3 casts would you prefer? Joshua Maurice <joshuamaurice@gmail.com> - 2011-09-01 15:37 -0700
                Re: which of these 3 casts would you prefer? gwowen <gwowen@gmail.com> - 2011-09-02 00:30 -0700
                Re: which of these 3 casts would you prefer? Miles Bader <miles@gnu.org> - 2011-09-03 18:26 +0900
      Re: which of these 3 casts would you prefer? Edek <edek.pienkowski@gmail.com> - 2011-08-26 15:29 +0200
      Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-08-27 09:35 -0700
        Re: which of these 3 casts would you prefer? Juha Nieminen <nospam@thanks.invalid> - 2011-08-27 18:38 +0000
          Re: which of these 3 casts would you prefer? Noah Roberts <roberts.noah@gmail.com> - 2011-08-27 12:32 -0700
            Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-08-27 14:51 -0700
              Re: which of these 3 casts would you prefer? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-29 14:10 +0000
                Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-08-30 07:23 -0700
            Re: which of these 3 casts would you prefer? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-29 11:32 +0000
          Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-08-27 14:37 -0700
            Re: which of these 3 casts would you prefer? Ian Collins <ian-news@hotmail.com> - 2011-08-28 10:06 +1200
              Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-08-27 15:27 -0700
                Re: which of these 3 casts would you prefer? Ian Collins <ian-news@hotmail.com> - 2011-08-28 10:47 +1200
                Re: which of these 3 casts would you prefer? Noah Roberts <roberts.noah@gmail.com> - 2011-08-27 15:42 -0700
                Re: which of these 3 casts would you prefer? Nobody <nobody@nowhere.com> - 2011-08-28 04:15 +0100
            Re: which of these 3 casts would you prefer? Noah Roberts <roberts.noah@gmail.com> - 2011-08-27 15:52 -0700
              Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-08-28 01:54 -0700
                Re: which of these 3 casts would you prefer? Keith H Duggar <duggar@alum.mit.edu> - 2011-09-04 19:16 -0700
            Re: which of these 3 casts would you prefer? Juha Nieminen <nospam@thanks.invalid> - 2011-08-29 18:16 +0000
              Re: which of these 3 casts would you prefer? Noah Roberts <roberts.noah@gmail.com> - 2011-08-29 16:35 -0700
                Re: which of these 3 casts would you prefer? Nobody <nobody@nowhere.com> - 2011-08-30 04:13 +0100
                Re: which of these 3 casts would you prefer? Juha Nieminen <nospam@thanks.invalid> - 2011-08-30 06:03 +0000
              Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-08-30 07:12 -0700
                Re: which of these 3 casts would you prefer? Juha Nieminen <nospam@thanks.invalid> - 2011-08-31 06:16 +0000
                Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-09-01 03:05 -0700
                Re: which of these 3 casts would you prefer? Juha Nieminen <nospam@thanks.invalid> - 2011-09-01 07:00 +0000
                Re: which of these 3 casts would you prefer? BGB <cr88192@hotmail.com> - 2011-08-31 13:21 -0700
          Re: which of these 3 casts would you prefer? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-28 19:30 +0000
      Re: which of these 3 casts would you prefer? Noah Roberts <roberts.noah@gmail.com> - 2011-08-27 12:19 -0700
        Re: which of these 3 casts would you prefer? Dombo <dombo@disposable.invalid> - 2011-08-28 12:08 +0200
        Re: which of these 3 casts would you prefer? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-28 19:44 +0000
          Re: which of these 3 casts would you prefer? Noah Roberts <roberts.noah@gmail.com> - 2011-08-28 13:41 -0700
    Re: which of these 3 casts would you prefer? Anand Hariharan <mailto.anand.hariharan@gmail.com> - 2011-08-26 07:30 -0700

csiph-web