Original date:2015-01-06 17:59:03 Edited by: petelomax Subject: Re: Try/Catch

mattlewis said...
petelomax said...

In addition there will also be a new builtin, throw(atom code).

Why an atom and not an object? It could be useful to put lots of stuff in there.

Maybe for version 2. Can we not just get an int (full 32-bit) working first?

mattlewis said...
petelomax said...

The call stack frame has a new machine-word-sized field, ehndlr. At startup, in the top-level...

Ugh...sorry, the implementation details lost me. Could you describe how all this would look to a euphoria programmer who knows nothing about the underlying implementation of euphoria?

OK, the same document with all the hidden back-end magic ripped out:

Draft Technical Spec

A new construct is to be added to the language:

catch e 
end try 

In addition there will also be a new builtin, throw(atom code).

The catch statement traps any exception within the try block or any routines it invokes that is not first caught by another nested try/catch statement. Any exceptions that must be re-thrown must be done so manually.

The exception variable, e in the above, though it can take any valid name that does not already exist in the immediately surrounding scope, is automatically declared as a sequence.

The sequence e always contains at least an exception code and address, but could also hold a routine number/name, and source code line number. The content beyond the first two elements may differ between interpreted and compiled applications, and the catch code block should be written to cope accordingly.

Obviously the application will terminate immediately (just like 9/0) should throw() be invoked when there is no active handler (try/catch construct) in the current call stack.

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu