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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c7f5c70275787af8 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Ada vs Delphi? Date: 1999/08/11 Message-ID: <7os8t1$fbd$1@nnrp1.deja.com>#1/1 X-Deja-AN: 511481243 References: <37ab421a.5414989@news.total.net> <37ab8bd1.0@news.pacifier.com> <37ae1fc8.653954@news.clara.net> <7olfni$jsu$1@nnrp1.deja.com> <37b129ae.43419124@news.total.net> X-Http-Proxy: 1.0 x38.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Wed Aug 11 16:37:54 1999 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-08-11T00:00:00+00:00 List-Id: In article <37b129ae.43419124@news.total.net>, aratel@total.net (Andre Ratel) wrote: > -= Mixing types =------------------------- > > I'm not sure I fully understand. Let's say n1 and n2 are known > to be non-negative integers (called cardinals in Delphi) but their > difference might be positive or negative. In Delphi, I would then > declare these variables as > > type > n1, n2: cardinal; > N21, N12: integer; > > and I could have something like > > begin > n1:= 0; > n2:= 8; > N21:= n2 - n1; > Writeln(IntToStr(N21)); > N12:= n1 - n2; > Writeln(IntToStr(N12)); > end; > > This seems OK with me and, with range checking off, would give the > right answers (8 and -8). On the other hand, a statement like > Writeln(IntToStr(n1 - n2)); > would give 4294967288. > > Now, with the above definitions of variables, a statement like > N21:= n2 - n1; > would not be valid with Ada? You definitely do NOT understand, which is not surprising since, as I expected, Delphi is not strongly typed in this area. Your view of types above is strictly structural, you declare things to be signed or unsigned according to their value range and then worry about mixing these values. That has nothing at all to do with the kind of strong typing we are talking about, where you have: type minutes is range 0 .. 59; type seconds is range 0 .. 59; mm : m; ss : s; Now mm and ss have IDENTICAL representation, but are of quite different types, so an assignment mm := ss; which is almost *certainly* a bug, is statically illegal, just as illegal in fact as trying to assign a record to an integer. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.