[Nickle]Boolean type, twixt, static vs global, built-in profiling
Keith Packard
nickle@nickle.org
Mon, 29 Jul 2002 09:25:23 -0700
Around 1 o'clock on Jul 29, Bart Massey wrote:
> If we leave things the way they are, we probably need to
> give up on the else clause of twixt(), and simply assert
> that everything should raise exceptions on failure. Right
> now, I'm having to write
> import File;
> twixt((file f = open("/tmp/foo", "w")), true; close(f)) {
That makes try_acquire much less useful; I'm not sure I want it raising an
exception when the mutex can't be grabbed.
But, the bool type has already helped me out:
if (a & b == 0)
Without the bool type, this typechecks just fine and gives the wrong
answer.
For your twixt example, really what you wanted was:
import File;
file f;
twixt (bool func () {
try {
f = open ("/tmp/foo", "w");
} catch open_error (string message, errorType error, string name) {
return false;
}
return true; } ();
close (f))
{
fprintf (f, "hello, world\n");
}
This turns the exception into an appropriate boolean; of course, the lambda
could check the errorType...
> Finally, Keith, I give up: I figured out how to turn on
> Nickle-statement-level profiling, and it looks from the
> source like just printing a function ought to now show its
> per-statement profile data, but I'm afraid I'm not having
> that experience. Suggestions?
Just a bug in the profile code when I converted to bool. Try
profile(false) for a good time, or update to current CVS :-)
-keith