Path: 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:  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