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


Groups > comp.programming > #6082

Re: Here is why C++ and C are bad...

From Richard Heathfield <rjh@cpax.org.uk>
Newsgroups comp.programming
Subject Re: Here is why C++ and C are bad...
Date 2015-12-30 16:35 +0000
Organization A noiseless patient Spider
Message-ID <n610v9$afu$1@dont-email.me> (permalink)
References (2 earlier) <n5v0di$7i3$1@dont-email.me> <n5v0p5$8s3$1@dont-email.me> <n6063m$ccb$1@dont-email.me> <n60m14$lf$1@dont-email.me> <87h9j06ip1.fsf@bsb.me.uk>

Show all headers | View raw


On 30/12/15 15:48, Ben Bacarisse wrote:

<snip>

> Since this is comp.programming, you should perhaps have said that mixing
> signed and unsigned expressions _in C_ is often a bad sign.  It may be
> in other languages too, but there are others in which it is both common
> and harmless.

Fair comment. So perhaps we could start by looking at how some other 
languages deal with unsigned integer types (or indeed whether they 
support them at all). I should say at the outset that the information I 
present below is unsatisfactorily sparse.

Ada supports signed and unsigned integer types. I couldn't find any 
rules on how mixed-sign arithmetic is done (but that doesn't mean there 
aren't any).

BASIC - tricky one. ISO/IEC 10279 defines the language, but I couldn't 
find a freely available draft.

COBOL (according to a rather strangely-formatted draft ISO Standard from 
2005) seems to support unsigned char, short, long, and even double. It 
isn't clear (from a quick scan) how COBOL deals with mixed-sign arithmetic.

D's rules are similar to C's. Particularly, if the two types are of the 
same size, then the signed type is converted to unsigned.

Eiffel supports unsigned integer types, but I found nothing in ECMA-367 
to show how they interact with signed types.

Fortran's draft standard (n3501) is rather odd. In Note 15.9 we find 
that "...Fortran does not provide direct support for unsigned kinds of 
integers", and yet in 4.4.1 Integer Type the text reads "The value of a 
signed integer zero is the same as the value of an unsigned integer 
zero", which suggests that there is /some/ kind of support for unsigned 
integers.

Go supports unsigned integer types, but a brief perusal of the spec 
didn't turn up any rules for mixed-sign arithmetic.

I ran out of time to extend this alphabetical list any further, but one 
of the first languages I thought of was PHP. I found it surprising that 
PHP doesn't appear to support an unsigned integer type (something that 
it has never before occurred to me to check, which suggests to me that I 
don't use PHP quite as often as I thought I did).

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-29 20:31 +0000
  Re: Here is why C++ and C are bad... Kaz Kylheku <kaz@kylheku.com> - 2015-12-29 21:20 +0000
  Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-29 23:13 +0100
    Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-29 22:19 +0000
      Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 09:56 +0100
        Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 13:28 +0000
          Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 14:55 +0100
            Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 16:32 +0000
              Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 18:17 +0100
                Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 20:01 +0000
          Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 15:48 +0000
            Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 16:35 +0000
              Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 18:19 +0100
                Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 17:39 +0000
                Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 20:26 +0000
              Re: Here is why C++ and C are bad... "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2015-12-30 18:32 +0100
              Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 19:55 +0000
                Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 20:15 +0000
                Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 22:00 +0000
      Re: Here is why C++ and C are bad... Ian Collins <ian-news@hotmail.com> - 2015-12-31 10:16 +1300

csiph-web