gm2
[Top][All Lists]
Advanced

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

Re: [Gm2] HALT procedure


From: Gaius Mulley
Subject: Re: [Gm2] HALT procedure
Date: Wed, 23 Aug 2017 11:38:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Tom Breeden <address@hidden> writes:

> On 08/21/2017, you wrote:
>
>> 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.
>>
>> Put another way, I get 'Aborted' as output when using HALT, but the XREF
>> and Processes examples in PIM seem to suggest that HALT is a the way of
>> ending the processing of the program before it has completed, the same
>> as GOTO 9999 in Pascal. The ISO standard, if memory serves, has a return
>> value of 0 (1 under Unix?) for HALT, if the parameter isn't specified, but
>> I get 134 when using HALT.
>>
>> Am I misunderstanding its use?
>
>
> It looks like ISO did define HALT similar to GOTO 99999, but
> there os a little more to the ISO behaviour.
>
>>From the ISO 10514-1 document: 
>
>     6.10.3.5 The Procedure HALT
>
>     The procedure HALT can be used to terminate the execution 
>     of a program at a point other than the end of the program
>     block.
>
>     A call of HALT shall have no actual parameters.
>
>     The call HALT shall be a program termination event - see 6.1.7
>
> And section 6.1.7 defines four ways program termination can be
> invoked:
>
>     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.   
>
> So like GOTO 99999, HALT does not imply an abnormal termination.
>
> 6.1.7 defines further rules describing what happens with execution
> of module termination sections and when c) and d) occur in
> a coroutine.
>
> ISO required system built-in modules EXCEPTIONS and TERMINATION
> provide procedures and functions for module termination sections
> to figure out what's going on at program ending.
>
> eg. functions 
>
>     PROCEDURE IsTerminating():BOOLEAN;
>       (* Returns TRUE if any coroutine has started  program
>          termination and FALSE otherwise. *)
>
>     PROCEDURE HasHalted(): BOOLEAN ;
>       (* Returns TRUE if a call to HALT has been made and FALSE
>          otherwise. *)
>
>     PROCEDURE IsExceptionalExecution 0: BOOLEAN;
>       (* If the current coroutine is in the exceptional execution
>          state because of the raising of an exception,
>          returns TRUE, and otherwise returns FALSE. *)
>
> tom

Hi Tom and David,

thanks for the bug report.  Indeed HALT as currently implemented assumes
abnormal termination (calls abort), which appears wrong!  I'll fix this
and write some test code for the regression suite,

regards,
Gaius





reply via email to

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