gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about behavior observed in gm2 [Funcation procedure calls]


From: Gaius Mulley
Subject: Re: Questions about behavior observed in gm2 [Funcation procedure calls]
Date: Tue, 05 Dec 2023 23:33:21 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

john o goyo <jog37@riddermarkfarm.ca> writes:

> Correcting two mistakes in my previous message:
>
> On 2023-12-04 18:12, john o goyo wrote:
>> On 2023-12-04 03:33, Gaius Mulley wrote (in part):
>>> Jack Perry <devotus@yahoo.com> writes(in part):
>> [...]
>>>
>>>> 3. If you neglect the parentheses on a function procedure that
>>>> takes no parameters, gm2 treats it as if you want the
>>>> address(?). Thus, the following line gives an unexpected answer:
>>>>
>>>>        InOut.WriteInt(Part1, 0); (* needs to be Part1() *)
>>> Interesting - and thanks for the bug report - I'll investigate the above
>>> two issues
>>
>> Why is this a bug?  I looked at ISO 1054-1 but being conversant with
>> the VDM used, I came away no wiser. However, the Lilith source has
>> hundreds of invocations of function procedures with trailing empty
>> parentheses.
>
> ISO 1054-1 should be ISO/IEC 10514-1; "but being conversant" should be
> "but not being conversant".
>
>>
>> Sincerely,
>> john
>>

Hi John,

maybe I misunderstood the original posting - I took it to mean something
similar to the code below.  Jack is this the issue?

$ cat gcc/testsuite/gm2/pim/fail/proccard.mod
MODULE proccard ;

FROM NumberIO IMPORT WriteCard ;
FROM StrIO IMPORT WriteString, WriteLn ;

PROCEDURE func () : CARDINAL ;
BEGIN
   RETURN 42
END func ;


BEGIN
   WriteString ('the value is: ') ; WriteCard (func, 5) ; WriteLn
END proccard.

which results in a clean compile :-)

I almost have a fix - which is currently generating a muddled up error
message (and a poor carot in the second message):

$ gm2 proccard.mod 
proccard.mod:13:48: error: parameter incompatibility when attempting to pass 
actual parameter ‘ADDRESS’ to a formal parameter ‘WriteCard’ during call to 
procedure ‘CARDINAL’
   13 |    WriteString ('the value is: ') ; WriteCard (func, 5) ; WriteLn
      |                                                ^~~~
proccard.mod:13:48: error: ‘ADDRESS’ and ‘CARDINAL’ are incompatible in this 
context
proccard.mod:13:57: error: 1st parameter type failure between actual parameter 
type ‘WriteCard’ and ‘ADDRESS’
   13 |    WriteString ('the value is: ') ; WriteCard (func, 5) ; WriteLn
      |                                                         ^
proccard.mod:13:57: error: ‘ADDRESS’ and ‘CARDINAL’ are incompatible in
this context

regards,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]