gm2
[Top][All Lists]
Advanced

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

Re: [Gm2] HALT procedure


From: Tom Breeden
Subject: Re: [Gm2] HALT procedure
Date: Thu, 28 Sep 2017 15:38:24 -0400 (EDT)
User-agent: YAM/2.10-dev (AmigaOS4; PPC; rv:20170901-12d33530)

On 09/28/2017, you wrote:

> David Egan Evans <address@hidden> writes:
>
>> The HALT procedure calls the C abort by default, which aborts the
>> program abnormally. Though this isn't explicit in PIM, I believe it is
>> in ISO/IEC 10514-1 (mainly because of the introduction of the parameter
>> for the program return value).
>>
>> More specifically, I understood that HALT (without parameters) should
>> behave as if the end of the program had been reached. This was added to
>> compensate for the removal of the GOTO, which in Pascal was typically
>> used to go the end of the file.
>
> Hi,
>
> firstly apologies for the delay in replying - I've been in the land of
> doom3 and teaching preparation.
>
> I've dug out my pim2, 3, 4 and ISO documents.  It does appear to me
> that HALT is designed for abnormal termination.  Even in the PIM
> examples XREF etc - the HALT always occurs if a fatal error is reached
> (file was not opened) in the XREF example.  Or in the processes
> example a runtime problem is detected before HALT is called.
>
> In ISO on page 40 it talks about
>
>>    a) the end of the normal part of the program module 
>>       initialization body is reached,
>>    b) a RETURN statement is executed in the program module
>>       initialization  body,
>>    c) the standard procedure HALT is called,
>>    d) an exception is raised and this exception is not handled.   
>
> and then goes on to categorise case (a) and (b) as normal termination.
> Which I conclude that (c) and (d) are abnormal termination.  So I think
> the current implementation is correct - unless I've misunderstood
> something?
>
> regards,
> Gaius
>

Not exactly. on the same page the ISO doc describes case c) and case d)
differently:

    Case c) does not change the execution state
    Case d) constitutes exceptional termination

In "termination" and in "exception" are independent states in ISO M2.

The rules for calling the FINALLY section of modules are always followed
for a terminating program.

EXCEPT module sections only cause termination on all the except
stack running off the end without a RETURN to clear or a RETRY to reenter
(or on calling HALT themselves).

Possibly for compatibility with PIM usage, ISO FINALLY sections can find
out whether any HALT was called and raise an exception if desired.

I'm not a C programmer (or much of any programmer right now), but it looks like 
exit() might be better than abort(). 

This is assuming that the clib atexit or on_exit structures are used in GM2. If
FINALLY calls are handled differently, it might not make any difference.

However, unless there is a "mission critical" ISO M2 program running somewhere
nowadays (which seems unlikely), it's probably not a big deal.

Tom




reply via email to

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