Article View: comp.lang.modula2
Article #4302from ORD to CARDINAL to CONVERT
From: Barry_Cornelius
Date: Thu, 30 Jun 1988 16:46
Date: Thu, 30 Jun 1988 16:46
58 lines
3763 bytes
3763 bytes
Alan Lovejoy <pdn!alan@NET.UU.UUNET> writes (28Jun at 04:48:57 GMT):
> Why not define ORD(aValueOfIntType) to be CARDINAL(aValueOfIntType)?
> That is, a meaning-preserving coercion into type CARDINAL? That way,
> you could just get rid of ORD altogether! Didn't the BSI/ISO committee
> propose doing just that a while ago? I seem to remember reading some
> such proposal in Modus Quarterly.
> For ORD(-1) (that is, CARDINAL(-1)) that would mean an exception, since
> there is no CARDINAL value that corresponds to -1 (by definition).
Well, please note that the text of my recent message about ORD
and VAL was actually written last September.
Alan is correct about recalling BSI recommendations. In a little
more detail, the BSI working group recommended to the ISO group:
(a) Kind of type change: "unsafe conversion" or "cast" or
"memory-preserving coercion" or
"subverts the type checking mechanism"
Currently done by constructs like: "CARDINAL(i)"
Proposal: use "CAST(CARDINAL,i)" having already done
"FROM SYSTEM IMPORT CAST".
(b) Kind of type change: "safe conversion" or "coercion" or
"meaning-preserving coercion"
Currently done by constructs like: "ORD('A')", "CHR(65)", ...
Proposal: ORD, CHR, FLOAT, TRUNC and VAL would be moved to
a module called Obsolete. Instead use
"CARDINAL('A')", "CHAR(65)", ...
Although proposal (a) has been accepted by the ISO Modula-2 working
group, proposal (b) was not accepted by the January 1988 ISO Modula-2
meeting. (* However, recent correspondence on this news group from
Albert Meier suggests that at least one of the members who voted
against proposal (b) would now like to change his mind. *)
The position proposed at the January meeting (which has since been
incorporated into the BSI working group's documents) is to
keep proposal (a) but to replace proposal (b) by:
(c) Kind of type change: "safe conversion" or "coercion" or
"meaning-preserving coercion"
Currently done by constructs like: "ORD('A')", "CHR(65)", ...
Proposal: ORD, CHR, ... would remain as at present
but VAL would be "deprecated". Instead use
"CONVERT(CARDINAL,'A')", "CONVERT(CHAR,65)", ...
Proposal (c) introduces a standard procedure called CONVERT
which is actually an enhanced version of VAL. The name "VAL" was not
chosen because (i) the new function is an enhanced version of VAL
and (ii) the name VAL would be confusing because it is now being used
by some implementations for "unsafe" conversions. The actual name
"CONVERT" wasn't liked by all members of the ISO/BSI working groups.
==
Barry Cornelius
==
Computer Science Group, School of Engineering and Applied Science,
University of Durham, Durham, DH1 3LE, England
JANET: Barry_Cornelius@uk.ac.dur.mts
Internet: Barry_Cornelius%mts.dur.ac.uk@cunyvm.cuny.edu
UUCP: ...ukc!cs.nott.ac.uk!bjc
BITNET/EARN: Barry_Cornelius%DUR.MTS@AC.UK
Tel: Durham (091 or +44 91) 374 2638, Secretary: 374 2630, Fax: 374 3740
Technical Details
Message-ID:
<INFO-M2%88063018035481@UCF1VM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!faline!thumper!ulysses!andante!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!durham.ac.UK!Barry_CorneliusShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!faline!thumper!ulysses!andante!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!durham.ac.UK!Barry_Cornelius From: Barry_Cornelius@durham.ac.UK.UUCP Newsgroups: comp.lang.modula2 Subject: from ORD to CARDINAL to CONVERT Message-ID: <INFO-M2%88063018035481@UCF1VM> Date: 30 Jun 88 16:46:59 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Info-Modula2 Distribution List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu> Organization: The Internet Lines: 58