Saturday, September 24, 2011

USL 3.7.0

I added exception-handling with the "try-catch-caught" keywords.  Believe it or not, it took me awhile to do this and I had ran into many complications until tonight when I found all I had to do was structure my code differently to utilize the benefits of try-catch-caught.  At first only an error in the try block would work correctly.  Now both erroneous and impeccable code works.  The original error message is contained in a keyword called "last_error" which may be assigned to a variable.  The variable is disposed after "caught" is called.  This is an extra garbage-handling feature I added.

The way my try statements work are as follows:

1. Try to parse code until "catch" keyword.
2. If an error occurs before "catch", stop parsing and skip to catch code.
3. If an error does not occur, skip catch code.
4. Parse until caught.

An example would be:
method test
                @var = 123.456789
                @var = "This will cause a conversion error."
                say "This will never be seen as an error already occurred."
                @e = last_error
                say "An error occurred: ${@e}"

        say "try-catch-caught may be used as many times as necessary."

Produces: An error occurred: conversion_error:@a

If an error does not occur, the catch code will not be parsed.  If an error does occur, parsing stops and USL automatically starts parsing the catch code until all is caught.  The caught keyword closes the try statement.  You may use try-catch-caught as many times as is needed.  Other languages exit the method/function after try-catch statements.  So that is another unique feature of USL that distinguishes it among other languages.

I've updated the MediaWiki and you can find it under the "Hosted Apps" tab at the sourceforge link below.

To download 3.7.0, you can visit any of the following links:


No comments:

Post a Comment