marekjm / viuavm

Parallel virtual machine designed to reliably run massively concurrent programs
https://viuavm.org/
GNU General Public License v3.0
71 stars 11 forks source link

Change throw-catch syntax #92

Closed marekjm closed 9 years ago

marekjm commented 9 years ago

Current syntax is strange, and repetitive - note the double use of try:

tryframe
catch "Type" handler
try blockname

New syntax - requiring new enter opcode (see issue #60 ) - would be more readable:

; tell the machine that a try will be issued
try
; register handlers for different types
catch "Foo" Foo_handler
catch "Bar" Bar_handler
enter dangerous_block

Apart from increased readability, as a bonus, simple block executes will be much more intuitive to write:

; assembler will automatically add try instruction to spawn tryframes
; configurable with -Etryless-enter or -Wtryless-enter
enter some_block
marekjm commented 9 years ago

The new syntax is also more consistent, a try (try) is signalled to the CPU and optional catchers are registered, then a block that should be tried is entered (enter), and is left (leave) some instructions later.