From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-20 12:24:25 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!skynet.be!skynet.be!fu-berlin.de!uni-berlin.de!213.200.246.247!not-for-mail From: Vinzent Hoefler Newsgroups: comp.lang.ada Subject: Re: Quality systems (Was: Using Ada for device drivers? (Was: the Ada mandate, and why it collapsed and died)) Date: Tue, 20 May 2003 21:23:17 +0200 Organization: JeLlyFish software Message-ID: References: <3ec4b1c9$1@news.wineasy.se> <9fa75d42.0305161748.1735fc32@posting.google.com> <4W%xa.28765$cK5.11964@nwrdny02.gnilink.net> <1053353256.804734@master.nyc.kbcfp.com> NNTP-Posting-Host: 213.200.246.247 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: fu-berlin.de 1053458664 28670675 213.200.246.247 (16 [175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:37565 Date: 2003-05-20T21:23:17+02:00 List-Id: Robert A Duff wrote: >Vinzent Hoefler writes: > >> Hyman Rosen wrote: >>=20 [modular arithmetic] >But it is not implementation defined in C. C requires unsigned >arithmetic to wrap around. Ada requires modular arithmetic to wrap >around (but allows an out for ones' complement machines). > >Signed arithmetic is unpredictable in C (in overflow cases). Yes, of course. I was referring to signed types only here. Sorry, if that didn't come out clear enough. And H.2.2 of the current C99-Standard says: |An implementation that defines signed integer types as also being |modulo need not detect integer overflow, in which case, only integer |divide-by-zero need be detected. Additionaly, J.3.5 definitely confirms that this is an implementation defined feature in C. >> >Doesn't Dewar rant on this subject occasionally? > >Yes, he does. I agree with him -- non-binary modulii are an unnecessary >frill, and should have been left out of Ada. Well, although myself I've never used them thus far, I'm sure there is something useful you can do with them. And if it's just to make the compiler writers crazy about that they have to support it... ;) > Consider the weird >semantics of "not" for non-binary modulii. Well, you get what you've asked for. :-) >> >> I doubt that. C just got modular types because it was convinient = and >> >> natively supported by the machine. >> > >> >That doesn't mean that Ada didn't copy the notion from C. >>=20 >> I still doubt that. And unless someone from the language designers can >> definitely confirm that, I will keep doing so. > >OK, I was on Ada 9X design team. The fact that other languages support >modular arithmetic was certainly one factor in the decision. Yes, of course. I didn't want to say that the Ada design team invented the wheel in that particular case. I just doubt that especially C was the main reason to have such type. >By the way, modular types is one of my least favorite features of Ada. >It's an odd mixture of high level and low level. For high-level >purposes, I'd rather have multi-word arithmetic, and do the "mod"s >explicitly when desired, and I don't want bit-wise "and" and the like. >For low-level purposes, I want bit-wise "and", but I don't want >non-binary modulii. Well, let's get an example out of my praxis. I got a kind of random lookup table with 15 entries (yes, I know, this is silly, especially because speed should have been a main concern when this was written first) and I just want to go through that array in circles. So using a modular type in that case would be what? Low level? High level? Currently this thing is written in assembly language, but if I'd ever reengineer that in Ada I'd definitely use a (non-binary) modular type for the index then (and an array with 16 entries instead). Of course, as you pointed out, I could do the modulo arithmetic by hand, but why if I can let the compiler handle it? >The design team actually went back and forth several times between two >solutions: a kludgy "magic" package that supports unsigned types of >certain sizes, pretty much like C, Well, I guess Interfaces.C comes quite close... >and a first-class type with syntax >and relatively general semantics (including non-binary modulii). >I think perhaps the magic package was the better solution. Well, I am no compiler writer, but I wouldn't consider that a use for another package [well, I *hate* using Interfaces.C, too ;-)]. After all, it's still some kind of Integer. YMMV. Vinzent. --=20 Parents strongly cautioned -- this posting is intended for mature audiences over 18. It may contain some material that many parents would not find suitable for children and may include intense violence, sexual situations, coarse language and suggestive dialogue.