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


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

Re: Why use C++?

From "Randy Brukardt" <randy@rrsoftware.com>
Newsgroups comp.lang.c++, comp.lang.ada
Subject Re: Why use C++?
Date 2011-08-10 17:37 -0500
Organization Jacob Sparre Andersen Research & Innovation
Message-ID <j1v17b$h98$1@munin.nbi.dk> (permalink)
References (1 earlier) <j1kaj8$dge$1@adenine.netfront.net> <1e292299-2cbe-4443-86f3-b19b8af50fff@c29g2000yqd.googlegroups.com> <j1tha5$11q5$1@adenine.netfront.net> <1fd0cc9b-859d-428e-b68a-11e34de84225@gz10g2000vbb.googlegroups.com> <9ag33sFmuaU1@mid.individual.net>

Cross-posted to 2 groups.

Show all headers | View raw


"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message 
news:9ag33sFmuaU1@mid.individual.net...
...
> In what way does Ada (95, or the current standard 2005) not support your 
> needs for unsigned types?

I'm not the OP, but...

> If you dislike the wrapping behaviour of the Ada "modular" unsigned types, 
> what is wrong with defining your own unsigned integer type in Ada, as in
>
>    type My_Number is range 0 .. 53621;

This does not work on the largest unsigned integer type (mod 2**32 in 
Janus/Ada). Ada 95 requires

    type My_Number is range 0 .. 2**32-1;

to be rejected, as the upper bound exceeds Max_Int. (This is technically a 
"signed_integer_type_definition", which shows the cause of the problem.)

The Janus/Ada intermediate code can generate overflow checks for the largest 
integer type, but I've failed to find any reasonable way to model such a 
type in Ada (assuming we want a real integer type, with numeric literals). 
The closest is the "non-standard integer type" is 3.5.4(26) -- but why 
should such a basic need be "non-standard"? And having it "non-standard" 
means that you can't use type declarations like the above to use it. Yuck.

There are uses for wrapping types, but they are far less likely than wanting 
overflow detection. The default should be to catch errors, not turn them 
into different ones.

Too late to fix, unfortunately.

                                                      Randy.





> or whatever range you need. This gives you non-wrapping arithmetic with 
> run-time checks for overflow, underflow, and range.
>
> -- 
> Niklas Holsti
> Tidorum Ltd
> niklas holsti tidorum fi
>       .      @       . 

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


Thread

Why use C++? Miro <nickbergeronsemail@gmail.com> - 2011-08-06 14:00 -0700
  Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-06 22:09 +0100
    Re: Why use C++? Stuart Redmann <DerTopper@web.de> - 2011-08-10 00:39 -0700
      Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-10 09:59 +0100
        Re: Why use C++? Stuart Redmann <DerTopper@web.de> - 2011-08-10 07:09 -0700
          Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-10 17:22 +0100
          Re: Why use C++? Niklas Holsti <niklas.holsti@tidorum.invalid> - 2011-08-10 22:05 +0300
            Re: Why use C++? "Randy Brukardt" <randy@rrsoftware.com> - 2011-08-10 17:37 -0500
              Re: Why use C++? Ludovic Brenta <ludovic@ludovic-brenta.org> - 2011-08-11 00:49 +0200
                Re: Why use C++? "Randy Brukardt" <randy@rrsoftware.com> - 2011-08-11 23:54 -0500
              Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-11 09:54 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-11 11:13 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-11 13:43 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-11 17:09 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-12 10:32 +0200
                Re: Why use C++? Hyman Rosen <hyrosen@mail.com> - 2011-08-12 09:15 -0400
                Re: Why use C++? "Randy Brukardt" <randy@rrsoftware.com> - 2011-08-12 17:09 -0500
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-12 19:20 +0200
                Re: Why use C++? Ludovic Brenta <ludovic@ludovic-brenta.org> - 2011-08-12 23:22 +0200
                Re: Why use C++? Ludovic Brenta <ludovic@ludovic-brenta.org> - 2011-08-16 06:06 -0700
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-13 11:37 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-13 12:27 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-15 13:38 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-13 13:02 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-12 11:21 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-12 16:30 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-12 22:05 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-13 11:15 +0200
                Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-13 21:29 +1200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-13 11:52 +0200
                Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-13 23:10 +1200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-13 13:46 +0200
                Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-14 08:30 +1200
                Re: Why use C++? Brian Drummond <brian@shapes.demon.co.uk> - 2011-08-13 11:54 +0000
                Re: Why use C++? Simon Wright <simon@pushface.org> - 2011-08-13 14:12 +0100
                Re: Why use C++? Brian Drummond <brian@shapes.demon.co.uk> - 2011-08-14 11:01 +0000
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-14 08:46 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-14 08:51 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-14 09:29 +0200
                Re: Why use C++? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-16 01:18 -0700
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-16 10:47 +0200
                Re: Why use C++? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-16 02:52 -0700
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-16 12:39 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-16 12:23 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-16 12:58 +0200
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-16 13:44 +0200
                Re: Why use C++? Bill Findlay <yaldnif.w@blueyonder.co.uk> - 2011-08-16 15:51 +0100
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-16 21:13 +0200
                Re: Why use C++? Bill Findlay <yaldnif.w@blueyonder.co.uk> - 2011-08-16 20:23 +0100
                Re: Why use C++? "Randy Brukardt" <randy@rrsoftware.com> - 2011-08-12 00:02 -0500
                Re: Why use C++? Robert Wessel <robertwessel2@yahoo.com> - 2011-08-12 00:16 -0500
                Re: Why use C++? Adam Beneschan <adam@irvine.com> - 2011-08-12 09:39 -0700
                Re: Why use C++? Paavo Helde <myfirstname@osa.pri.ee> - 2011-08-12 01:51 -0500
                Re: Why use C++? Georg Bauhaus <rm.dash-bauhaus@futureapps.de> - 2011-08-12 09:41 +0200
                Re: Why use C++? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2011-08-12 11:40 +0200
                Re: Why use C++? Stuart Redmann <DerTopper@web.de> - 2011-08-12 04:48 -0700
                Re: Why use C++? "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> - 2011-08-12 15:12 +0200
                Re: Why use C++? Stuart Redmann <DerTopper@web.de> - 2011-08-12 08:50 -0700
                Re: Why use C++? Bill Findlay <yaldnif.w@blueyonder.co.uk> - 2011-08-12 18:02 +0100
                Re: Why use C++? "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> - 2011-08-15 14:59 +0200
                Re: Why use C++? Louisa <louisa.hutch@gmail.com> - 2011-08-18 06:39 -0700
          Re: Why use C++? Colin Paul Gloster <Colin_Paul_Gloster@ACM.org> - 2011-08-11 10:02 +0000
      Re: Why use C++? Dombo <dombo@disposable.invalid> - 2011-08-11 20:20 +0200
        Re: Why use C++? Lynn McGuire <lmc@winsim.com> - 2011-08-11 14:50 -0500
        Re: Why use C++? Dombo <dombo@disposable.invalid> - 2011-08-12 19:22 +0200
    Re: Why use C++? Miro <nickbergeronsemail@gmail.com> - 2011-08-13 08:37 -0700
      Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-14 08:38 +1200
        Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-14 10:41 +1200
          Re: Why use C++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-14 07:26 +0000
            Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-14 20:18 +1200
              Re: Why use C++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-14 09:00 +0000
        Re: Why use C++? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-16 02:10 -0700
          Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-16 21:25 +1200
            Re: Why use C++? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-16 02:54 -0700
              Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-16 22:04 +1200
  Re: Why use C++? Ian Collins <ian-news@hotmail.com> - 2011-08-07 09:10 +1200
    Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-06 22:13 +0100
      Re: Why use C++? Juha Nieminen <nospam@thanks.invalid> - 2011-08-07 09:09 +0000
        Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-07 12:37 +0100
          Re: Why use C++? Juha Nieminen <nospam@thanks.invalid> - 2011-08-07 14:52 +0000
            Re: Why use C++? "Paul" <pchristor@yahoo.co.uk> - 2011-08-07 20:21 +0100
  Re: Why use C++? Lynn McGuire <lmc@winsim.com> - 2011-08-06 16:29 -0500
  Re: Why use C++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-07 09:35 +0000
    Re: Why use C++? "crea" <no@invalid.com> - 2011-08-07 13:40 +0100
  Re: Why use C++? Dombo <dombo@disposable.invalid> - 2011-08-07 15:12 +0200
    Re: Why use C++? Juha Nieminen <nospam@thanks.invalid> - 2011-08-07 14:55 +0000

csiph-web