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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,4873305131bf4d94 X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,4873305131bf4d94 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,4873305131bf4d94 X-Google-Attributes: gid103376,public From: kaz@helios.crest.nt.com (Kaz Kylheku) Subject: Re: Porting Experiences (was Ada and Pascal etc ) Date: 1997/11/04 Message-ID: <63obnf$m3l$1@helios.crest.nt.com>#1/1 X-Deja-AN: 287057041 References: <34557f2b.1934172@news.mindspring.com> <345E3ACD.A15@gsg.eds.com> <63mcmm$r3s$1@helios.crest.nt.com> <01bce929$4a8cbe80$560b6dce@my-pc.neosoft.com> Organization: A poorly-installed InterNetNews site Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ Date: 1997-11-04T00:00:00+00:00 List-Id: In article <01bce929$4a8cbe80$560b6dce@my-pc.neosoft.com>, Pat Rogers wrote: >Kaz Kylheku wrote in article ><63mcmm$r3s$1@helios.crest.nt.com>... >> In article <345E3ACD.A15@gsg.eds.com>, >> Shmuel (Seymour J.) Metz wrote: >> >Craig Franck wrote: >> > >> >> What is it about Ada that makes it portable? >> > >> >How about the ability to define variables by their range instead of >> >using implimentation-dependent terms like long and short? That's >> >certainly the most glaring deficiency in C with regard to portability. >> >> That depends on how you look at it. I'd say that it requires a little >> more thought and skill to write portably with types that have sizes >> that are not fully specified, but it's not impossible. >> >> C gives you a header, , which gives you the constants LONG_MIN >> and LONG_MAX. These tell you what the implementation's least and >> greatest values of type long are. These values are guaranteed to be >> at least -2^31+1 and 2^31-1 respectively. >> >> If you assume that the long type has a range that is no larger than this, >> you are OK. If you write your code under the assumption that the >> range is LONG_MIN to LONG_MAX, you are also OK. > >That's missing the point. By having application-specific ranges for >integers and accuracy for floating point types, an Ada programmer finds out >*at compile time* that their new target cannot handle the program they are >porting. But then the program is not portable. You are no longer talking about portable programming. Your Ada program has failed to translate for a target for which a conforming Ada implementation exists. It is therefore not a portable Ada program. I'm talking about writing programs that work anywhere, for which it is not acceptable to fail to translate. I don't think that I'm missing the point. What if you _have_ to get that program running on that target? You have some revising to do, in effect creating a new variant of that program which is more portable. In C you can also write programs that fail to translate depending on the capabilities of the target. E.g. #include #if CHAR_BIT != 9 #error require a 9 bit char #endif but this sort of thing isn't of particular interest to programmers who keep utmost portability in mind. It's not an acceptable answer to issues of portability. >Sure, we can all play with assuming what the portable ranges are, >but compile-time checking finds them earlier and thereby cheaper, than In C, the portable ranges are given to you by the standard, so there is no need to find them at compile time. >hopefully having users detecting a bug. In Ada, we know predefined Integer >is at least 16 bits, but best approach is to avoid it when possible, since >the more portable alternative is available. What is the more portable alternative? To declare a type that has the specific range -32767 to 32767? This has some clear advantages over using plain Integer, but I don't see portability as being one of them. Or are you worried about some implementation of Ada which only gives you a 15 bit Integer? Would that not be a non-conforming implementation? -- "In My Egotistical Opinion, most people's C programs should be indented six feet downward and covered with dirt." -- Blair P. Houghton