🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #972

Re: PIM3/PIM4 and JPI M2

#972
From: Jens Tingleff
Date: Wed, 25 Jul 1990 07:40
75 lines
3170 bytes
Pat.Terry@p101.f4.n494.z5.fidonet.org (Pat Terry) writes:


[....]

>If you have 
>DEFINITION MODULE a;
>  FROM x IMPORT y;
> ...
>END a.
>then in PIM I think you have to write
>IMPLEMENTATION MODULE a;
>  FROM x IMPORT y (*again*);
> ...
>but in JPI you do not.

Not to turn this into any sort of super-correctness-war, but PIM2 ed 3 
ref. man. sect 14 page 168 has

	"..Definition and implementation modules exist in pairs. Both
	 may contain import lists, and all objects declared in the
	 definition module are available in the corresponding
	 implementation module without explicit import"

"Ahh", I hear you cry (and my self as well), "it says declaration, not
import". Well, I'd say an import was a declaration, refering to sect 4,
page 146, of same work, scope rules augmentations:

	"3. If an identifier defined in a module M1 is exported, the scope
	 expands over the block which contains M1. If M1 is a compilation
	 unit (see Ch 14), it extends to all those units which import M1"


This is the sort of thing a lot of compiler writers like to get wrong... .

[..]

>In JPI the type casting of the form CARDINAL(g), INTEGER(g), REAL(h) is not  
>"casting" or coercion at all, but conversion (like using VAL.

Well: PIM2 ed3 is very careful to mention the fact that
`type transfer functions' are implementation defined. It says in chapter
29, page 125 top, 

	".... The key idea behind these type transfers is,
	 however, that they do not involve any actual computation. .."

what is meant by ``"casting" or coercion'' above ? The example below
is what an article in PCW (Personal COmputer World) claimed to be alright,
in a M-2 series they had some time ago.

VAR
  r : REAL; i : INTEGER;
BEGIN
  i := VAL(INTEGER, r);		(* NO NO NO *)
END.

which I'm sure is wrong. The `FLOAT()' and `TRUNC()' functions should
(surely) be used. PIM2 ed 3 ref man sect 10.2 describes the VAL function 
as
	"VAL(T,x)	the value with ordinal number x and with type T.
	 		T is any enumeration type, or CHAR, INTEGER
			or CARDINAL. VAL(T, ORD(x)) = x, if x is of type T."

So, both the `type transfer functions' and VAL will simply alter
the apparent type (apart from byte -> longword conversions in VAL),
no "casting" (in, e.g., the C sense, where ``int i; double r = (double)i;''
performs computation). Please correct me if I'm wrong, I know I'm confused..

	Jens

Jens Tingleff MSc EE, Institute of Computer Science, Copenhagen University
Snail mail: DIKU Universitetsparken 1 DK2100 KBH O
"It never runs around here; it just comes crashing down"
	apologies to  Dire Straits 
Technical Details
Message-ID: <1990Jul25.074022.21528@diku.dk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!apple!rutgers!cmcl2!uupsi!sunic!dkuug!freja.diku.dk!skinfaxe.diku.dk!jensting
References: <2028.26AAA196@puddle.fidonet.org>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!apple!rutgers!cmcl2!uupsi!sunic!dkuug!freja.diku.dk!skinfaxe.diku.dk!jensting
From: jensting@skinfaxe.diku.dk (Jens Tingleff)
Newsgroups: comp.lang.modula2
Subject: Re: PIM3/PIM4 and JPI M2
Message-ID: <1990Jul25.074022.21528@diku.dk>
Date: 25 Jul 90 07:40:22 GMT
References: <2028.26AAA196@puddle.fidonet.org>
Sender: news@diku.dk (The Netnews System)
Organization: Department Of Computer Science, University Of Copenhagen
Lines: 75