[Nickle]Boolean type, twixt, static vs global, built-in profiling
Keith Packard
nickle@nickle.org
Mon, 29 Jul 2002 13:00:07 -0700
Around 12 o'clock on Jul 29, Bart Massey wrote:
> try_acquire() is just a bad idea anyhow :-). But to take a
> page from your book, why not just write this?
> exception no_acq();
> try {
> twixt(bool func(){ if (!try_acquire(m)) raise no_acq();}();
> release(m)) {
> ...
> }
> } catch no_acq() {
> ...
> }
Hmm. Perhaps the elements of the twixt could be statements instead of
expressions?
twixt (if (!try_acquire ())
raise no_acq ();
release())
{
}
> Perhaps we need a smalltalk-like "block expression" that works something like
> (func x *= x; return x + y;)
GCC already has something like this, the syntax is:
({ x *= x; })
But, it's defined to have a void type; we could extend the syntex to permit
return which could give a non-void value. That would make our try_acquire
block look more like:
twixt (({ if (!try_acquire()) raise no_acquire(); }); release()) {
}
That almost looks sensible now.
> While I'm at it, we probably need a builtin apply()
> where
> poly apply(poly fn(...), poly[*] args)
> and the actuals in the array are supplied as the formals of
> fn(). Obviously, static typechecking goes out the window
> here, at least for now. C'est la vie.
Actually, we could invert the current varargs syntax:
int foo (int i, int j, int k) {}
int[*] b = { 1, 2, 3 };
foo (b...)
This would retain the same level of typechecking that the current varargs
stuff does.
-keith