From: Twylite <tw...@cr...> - 2008-12-12 00:09:07
|
Okay, I found some time to work on the reference implementation. Changes: - 'throw' has behavior consistent with 'error'. The 'interp alias' approach that was suggested behaves weirdly if you don't get the arguments right, so the implementation is proc-based. - removed the 'as {resultsVar optionsVar}' clause and introduced per-handler variable assignment - improved error messages - improved behavior of '-during' - added tests (there are just under 100 tests covering most aspects of the functionality; more to come) Outstanding issues: - In the case of a fallthrough body "-", to which variable(s) should the outcome of the try body be assigned? e.g. try { throw FOO bar } trap FOO {em1 opts1} - trap BAR {em2 opts2} { puts body } It seems logical that the variables for the BAR case may be expected by the BAR body and should be set; but what about those for the FOO case? Option #1: set the FOO case variables only; making sure the body works correctly is the developer's problem Option #2: set the BAR case variables only; the fact that the FOO variables are left unset is a quirk of using the "-" syntax Option #3: set the FOO and BAR variables; possibly more consistent from the developer's perspective, but adds complexity to any implementation that is aiming for performance Option #4: sets the FOO and BAR variables as well as those of any other fallthrough cases in between, also at a cost in complexity/performance terms The current implementation provides Option #2, but this is strictly a side-effect of the implementation and easily changed to #1 or #4 (#3 is a bit of a pain). - Some corner cases around when "-during" should or should not be added to the options dict. Updated version available at http://www.crypt.co.za/pub/try-2.tcl . Regards, Twylite |