|
From: | Fischlin Andreas |
Subject: | Re: proctype and procedure type checking fully implemented |
Date: | Sun, 21 Apr 2024 15:24:18 +0000 |
Dear Benjamin, See below:
Sorry, we are talking here only about assignment compatibility as the formal parameter of WriteCard is by value. In M2 assignments such as x := y; or y := x; with VAR x: CARDINAL; y: INTEGER; have always been legal. Not only in Pascal, but also in Modula-2. The only additional effort needed by a compiler is to generate code that checks for range errors at run time as INTEGER and CARDINAL typically overlap only by the upper (positive) half of INTEGER. BTW, I took out my old Classic Mac and tested with MacMETH, one of the best PIM compilers, which was first largely written by Niklaus Wirth himself. Compile and run-time errors are encountered exactly for the cases as described in my previous e-mail. I do not see that here would be any type promotion necessary. A statement such as WriteCard (func(), 5) merely requires assignment compatibility as func is implicitly executed, and the result returned. The actual parameter for any by value formal parameter can be an _expression_. Thus a statement such as WriteCard (func() + 1, 5) is also fully legal M2. Otherwise a statement such as x := y + 5; would also not be legal M2. Of course x := x + y; is illegal as a mixed type _expression_ results. But this does not exclude assignment compatibility between INTEGER and CARDINAL. Right, Benjamin? ;-) Andreas
|
smime.p7s
Description: S/MIME cryptographic signature
[Prev in Thread] | Current Thread | [Next in Thread] |