Commit ded52d24 authored by Luke  Thorpe's avatar Luke Thorpe
Browse files

Cleared up ambiguity to 'Gap 2'

parents 248ba7e1 c8401519
No preview for this file type
......@@ -365,11 +365,9 @@ The type of the expression given to the return statement must match the return t
Once the return statement is executed, the function is immediately exited.
\paragraph{Exit Statements:}
\hl{If in a function body, an exit statement must be at the very end, or a semantic error will be thrown.
In the main program, everything after the exit statement will not be processed.
The expression given to the exit statement must evaluate to an integer. Once the
exit statement is executed, the function/program is immediately exited with exit code
given by the integer that its sub-expression evaluates to.}
\hl{An exit statement }\lit{exit}\hl{ is used terminate the execution of the running program with a particular exit code. The statement is given an expression that must evaluate to a value with type }\lit{int}\hl{ (with 0 and 1 typically denoting success and failure respectively).}
\hl{Upon encountering an exit statement, a program will terminate immediately after the given expression has been successfully evaluated; any code thereafter will be ignored. }
\fillgap{\hl{define exit statements}}{2 marks}
\paragraph{Print Statements:}
......
# exit instead of returning from a function
# Output:
# #empty#
# Exit:
# 42
# Program:
begin
char f() is
exit 42
end
char c = call f() ;
println c ;
exit 0
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment