Re: checkAccess(AccessMode... modes) is void
ram@zedat.fu-berlin.de (Stefan Ram) writes:
OK, but what has become of the exception style policies saying
that one should use exceptions only for exceptional situations
and not as a means to return information?
Using exceptions for general control flow has some beauty,
but one might then need to change the name of the game.
I could imagine some similar general ?callback? feature:
call // think of "try"
{ getTime(); }
// now think of "catch"
accept time( final int hours, final int minutes, final int seconds )
{ ... }
// now think of another "catch"
accept timeNotAvailble()
{ ... }
Here, ?getTime()? will call ?time? when it was able to get a
time and ?timeNotAvailable()?, otherwise.
public void getTime()
{ ...
/* to return the normal result */
callback time( h, m, s ); // exits this methods and goes to the
// callers acceptor with a matching prototype
...
/* to return the error information */
callback timeNotAvailable();
... }
Somewhat reminds me of Hewitt's actors:
http://en.wikipedia.org/wiki/Actor_model
, where, IIRC, calls never return.
OTOH this can nearly be done today:
getTime
( new TimeArgument()
{ void time( final int hours, final int minutes, final int seconds )
{ ... }
void timeNotAvailable()
{ ... }} );
public void getTime( final TimeArgument argument )
{ ...
argument.time( h, m, s ); return;
...
argument.timeNotAvailable(); return; }