🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #2515

Re: Modula-2, Modula-3, C or C++

#2515
From: Mike Stark
Date: Wed, 20 Sep 1995 13:26
47 lines
3171 bytes
ohk@hal.nta.no (Ole-Hjalmar Kristensen TF.E/DELAB) wrote:
>In article <BLUME.95Sep15102347@dynamic.cs.princeton.edu>, blume@dynamic.cs.princeton.edu (Matthias Blume) writes:
<<editing of much e-mail address stuff>>
>|>
>|>    What worries me is that there does not seem to be a clean way to ensure that a
>|>    record has a specific *physical* layout. If it is to be used for systems
>|>    programming, I think this is an important feature, because there is often a need
>|>    to interface to devices which expect to use a fixed data format.
>|>
>|> If you had read the C standard or any of the more popular documents
>|> describing it then you would know that neither C nor C++ give you such
>|> a guarantee either.
>|>
>|> --
>|> -Matthias
>
>What makes you think I haven't read it? I was just complaining that Modual-3 does
>not provide it.
>
>Btw, I don't particulary like the lack of specification of basic types like int,
>short, etc. in C/C++ either, and Ada isn't much better, which we discovered when
>using a validated Ada compiler which only had 16 bit int's, even though the CPU
>on which it was running had a 32 bit CPU!
>
>Ole-Hj. Kristensen

Ada has the advantage of letting you define layout for data explicitly, i.e.

type REAL_DATA is digits 15;
for REAL_DATA'size use 64;

will allocate 64 bits for variables of type REAL_DATA.  Looking in the Ada reference
manual there also seem to be ways to fix the internal representation (mantissa and exponent size) of a floating point data item.

This is the theory, anyway.  In practice, I believe compiler vendors have had some discretion over what representation clauses are or are not supported, and even full
support doesn't solve all your problems. when the same file can be generated on multiple machines with multiple data representations  I don't think there is really any substitute for settling on a standardized representation for data, such as XDR (which is what we
at GSFC's Flight Dynamics Division have ended up doing).

Please pardon the lack of C++ on this post.  Since the representation clauses aren't part of C++ or Modula, maybe some enterprising soul can market a class library to create
similar capabilities.  This probably should even be done in Ada, since some of these
issues go beyond what the representation language features do for you.

Mike
Technical Details
Message-ID: <43p4qg$9lv@post.gsfc.nasa.gov>
Path: arc1-ca.pugleaf.net!newsfeed.gsfc.nasa.gov!usenet
References: <438nkr$bd@classic.eng.octel.com> <4395o4$3mv2@news-s01.ny.us.ibm.net> <43bdus$l2g@nntp.nta.no> <BLUME.95Sep15102347@dynamic.cs.princeton.edu> <43jsfd$1ea@nntp.nta.no>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newsfeed.gsfc.nasa.gov!usenet
From: Mike Stark <michael.e.stark@gsfc.nasa.gov>
Newsgroups: comp.lang.modula2,comp.lang.modula3,comp.lang.c,comp.lang.c++
Subject: Re: Modula-2, Modula-3, C or C++
Date: 20 Sep 1995 13:26:40 GMT
Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
Message-ID: <43p4qg$9lv@post.gsfc.nasa.gov>
References: <438nkr$bd@classic.eng.octel.com> <4395o4$3mv2@news-s01.ny.us.ibm.net>  <43bdus$l2g@nntp.nta.no> <BLUME.95Sep15102347@dynamic.cs.princeton.edu> <43jsfd$1ea@nntp.nta.no>
NNTP-Posting-Host: fdf-int-sser.gsfc.nasa.gov
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Mailer: Mozilla 1.1N (Macintosh; I; 68K)
X-URL: news:43jsfd$1ea@nntp.nta.no