rrthomas / mit

A simple stack-based VM
Other
10 stars 3 forks source link

Unify description of call frames, error handlers, and call/ret #366

Closed apt1002 closed 4 years ago

apt1002 commented 4 years ago

Maybe describe it as a three-level structure. First describe a stack of words (replace - with ->), then a stack of frames, then a stack of catch blocks. Define the || notation, and introduce a similar notation for catch blocks.

Need to define "the caller" in section errors.

Separate the concept of normal return, which returns values, from exceptional return, which does not. Say that error codes are non-zero; don't say that zero is an error code. Specify the behaviour of 0 throw.

rrthomas commented 4 years ago

I have now addressed this in the commit mentioned above; please could you review, @apt1002? I have not made 0 something other than an error code, because I think that introduces more complexity than it solves. It's fairly common for an exit status to be what we might think of in a richer type system as a "Maybe(Error)", for example process exit codes. My counter-suggestion is therefore to rename "error code" to something more neutral, say, "status code".

rrthomas commented 4 years ago

We have replaced "error code" with "status code", and proposed further improvements to the definition of stack pictures in issue #404.