Article View: comp.lang.modula2
Article #4314Re: from ORD to CARDINAL to CONVERT
From: Claudio Nieder
Date: Tue, 05 Jul 1988 00:37
Date: Tue, 05 Jul 1988 00:37
41 lines
2760 bytes
2760 bytes
In article <INFO-M2%88063018035481@UCF1VM| Info-Modula2 Distribution List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu> writes:
|(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
Why introduce another standard procedure, when you can use the elegant
solution (b). I agree, that it is a good idea to introduce CAST, to force
the programmers who do unsafe conversion to have a FROM SYSTEM IMPORT...
line in their program. But I don't see the need for a CONVERT procedure.
IT happens often, that you have CARDINAL as well as INTEGER variables in
your program, and that you have to convert one type into the other.
So it's better to have a simple mean to do that ( CARDINAL(i) ) instead
of a more complicated one ( CONVERT(CARDINAL,i) ).
claudio
Technical Details
Message-ID:
<349@forty2.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!cernvax!ethz!forty2!claudioReferences:
<INFO-M2%88063018035481@UCF1VM|Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!cernvax!ethz!forty2!claudio From: claudio@forty2.UUCP (Claudio Nieder) Newsgroups: comp.lang.modula2 Subject: Re: from ORD to CARDINAL to CONVERT Message-ID: <349@forty2.UUCP> Date: 5 Jul 88 00:37:36 GMT References: <INFO-M2%88063018035481@UCF1VM| Reply-To: claudio@forty2.UUCP (Claudio Nieder) Organization: Exp. Physics University Zuerich Lines: 41