Article View: comp.lang.misc
Article #183Re: Fortran90 and Arrays
From: Peter da Silva
Date: Mon, 13 Apr 1992 17:51
Date: Mon, 13 Apr 1992 17:51
47 lines
2891 bytes
2891 bytes
In article <STEPHEN.92Apr11201347@estragon.uchicago.edu> stephen@estragon.uchicago.edu (Stephen P Spackman) writes:
> In article <id.6DTO.VWK@ferranti.com> peter@ferranti.com (Peter da Silva) writes:
> | The word `type' refers to the set of operations that may
> | be performed on a collection of data.
> This is still a little buggy. Consider the (constructed :-) example of
> a language that has two mappings from the same _abstract_ type to the
> same storage format - say 1-s and 2-s complement integers (or an int
> and an unsigned both being used to hold numbers between 1 and 100, a
> very common case in C).
> Now the same "operations", like +, may be available for both, even
> with the same meanings.
If the two objects have the same operations with the same meanings they
have the same type.
If the two objects have the same operations with the same meanings over
some range of values, and different meanings over other ranges of values,
then you can't say they have the same operations nor that they are the
same type.
In C, the type is bound to the identifier, so you can set up an alias
for a collection of data that treats it as a different type. But the
type can still be defined as the set of operations you can perform on
that data. This is referred to in C as "type punning" and is considered
as bad thing.
In Fortran, type punning is not possible in legal programs, but few if
any compilers prevent you from using (for example) implicit aliasing of
function arguments to cause type punning.
In languages where the type is bound to the data the whole concept is
meaningless. This has advantages and disadvantages. It costs some in
performance and you can't take advantage of the tools the language
provides to prevent type punning and enforce design rules, but it also
makes it easier to trace when you slip a design rule violation past
the compiler.
Some object oriented languages allow you to provide explicit assertions
about design rules that provide the same sort of protection, and also
help optimisation.
--
/F{findfont exch scalefont setfont}def /S{moveto show}def /T{/Times-Roman F}def
8 T(Ferranti International Controls Corporation)24 28 S(+1 713 274 5180)24 12 S
(Sugar Land, TX 77487-5012)24 20 S 12 /Courier F(`-_-')320 32 S( 'U` )320 16 S
12 T(Peter da Silva)24 36 S 16 T(Have you hugged your wolf today?)358 24 S
Technical Details
Message-ID:
<id.OCVO.D6A@ferranti.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!ficc!peterReferences:
<1992Apr8.180420.9294@newshost.lanl.gov> <id.6DTO.VWK@ferranti.com> <STEPHEN.92Apr11201347@estragon.uchicago.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!ficc!peter From: peter@ferranti.com (Peter da Silva) Subject: Re: Fortran90 and Arrays Message-ID: <id.OCVO.D6A@ferranti.com> Sender: peter@ferranti.com (peter da silva) Organization: Xenix Support, FICC References: <1992Apr8.180420.9294@newshost.lanl.gov> <id.6DTO.VWK@ferranti.com> <STEPHEN.92Apr11201347@estragon.uchicago.edu> Date: Mon, 13 Apr 1992 17:51:54 GMT Lines: 47