Huh?
value_with_default(m->foo, "bar");
You're asuming that the exception is stored together with the value? That's not how exceptions work in any language I'm familiar with, it would be raised when the value is computed, terminate the normal flow of control, and the helper function would never be called.
I'm afraid I'm totally lost here, even if storing arbitrary exceptions with a value would be a creative extension of the zero_type hack.
/ Niels Möller ()
Previous text:
2003-01-28 13:56: Subject: Re: zero_type() & UNDEFINED and _typeof()
Define a utility function when you need it? :-)
mixed value_with_default(mixed value, mixed default) { return exceptionset(value)->no_value ? default : value; }
/ Leif Stensson, Lysator