I think the exception thing would work if there was some syntax sugar and a decent exception hierarchy.
try { mixed x = foo(); werror("The value is %O\n", x); } except { no_value: werror("No value\n"); }
One would also want some syntax sugar to make m[foo] | "bar" work (and do the right thing, with "bar" used iff m[foo] doesn't exist). It's hard to cook up a good syntax. Perhaps a trinary or n-ary !: could work (by a stretch analogy with trinary ?):
m[foo] ! no_value : "bar"
/ Niels Möller ()
Previous text:
2003-01-23 17:06: Subject: Re: zero_type() & UNDEFINED and _typeof()
I think that
mixed x = foo(); if(zero_type(x)) { werror("No value\n"); } else { werror("The value is %O\n", x); }
is much better than
mixed x; mixed y = catch(x = foo()); if(!y) { werror("The value is %O\n", x); } else if(!arrayp(y) && !(objectp(y) && y->is_generic_error)) { werror("No value\n"); } else { throw(y); }
though.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)