AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
finally grammar
 
A finally statement asks the Yoix interpreter to execute some code right before the current block ends. Its usage description can be summarized as follows:
Statement:
	finally Compound

The Yoix implementation of finally, unlike the Java version, is not tied to try and there are no restrictions on the number of finally statements in any block - the last one executed by the interpreter is the only one that gets kicked off when the block ends. In other words, the interpreter has to reach and execute the finally statement before you can be sure it will get kicked off at the end of a block; just because you can see a finally statement somewhere inside a block doesn't mean anything special will happen when the block ends.

When a block is about to end, the Yoix interpreter executes the code associated with the last finally statement that it encountered in the block and then it restores saved variables in the opposite order that they were saved. Even though finally can restore variables, save is more efficient and is the only way to reset access permissions.
 
 Example:   The program
import yoix.stdio.*;

int  n = -100;
{
    int  n = 100;
    finally {
        printf("this will not execute\n");
    }
    n++;
    finally {
        printf("local n=%d\n", n);
    }
    n++;
}

n--;
finally {
    printf("global n=%d\n", n);
}
n--;
prints
local n=102
global n=-102
on standard output.
 
 See Also:   reference, save

 

Yoix is a registered trademark of AT&T Inc.