Hacker News new | past | comments | ask | show | jobs | submit login

The language Nickle (http://nickle.org) has a "twixt" control structure:

    twixt (expression1, expression2)
           statement1
If expression1 is true, then statement1 will be executed followed by expression2 in that order. The twixt statement guarantees that expression2 is always executed if expression1 is true, similarly to how "finally" works in java.



> If expression1 is true, then statement1 will be executed followed by expression2 in that order. The twixt statement guarantees that expression2 is always executed if expression1 is true, similarly to how "finally" works in java.

Am I missing something here? How is that different from, say:

    if (expression1) {
        statement1
        expression2
    }

?


It's different in that expression1 is always evaluated whenever control enters the twixt and expression2 is always evaluated whenever it leaves. A simple example is that if statement1 throws an exception, then expression2 is evaluated before the exception is handled. This is how finally works in Java.

More interestingly, Nickle has support for continuations, so if statement1 generates a continuation and makes a non-local exit, then expression2 is evaluated before that exit, and expression1 is evaluated before the continuation is resumed.

In other words, statement1 is always bracketed by expression1/expression2, even in the presence of non-local control flow.


Aha! Thanks for clearing that up.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: