Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Modula 3 > Exceptions for ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 65 of 148
Post > Topic >>

Exceptions for call-back functions

by Henning Thielemann <iakd0@[EMAIL PROTECTED] > Oct 7, 2003 at 10:22 AM

I'm uncertain what exceptions I should allow for a callback function.
Since I don't know what exception the callback may raise I had to allow
ANY ? To take the example from
 http://research.compaq.com/SRC/m3defn/html/procs.html
 I had to declare

    TYPE
      Integrand = PROCEDURE (x: REAL): REAL RAISES ANY;
      Integrator = PROCEDURE(f: Integrand; lo, hi: REAL): REAL RAISES ANY;

 . Everyone who calls an Integrator has to provide a TRY..ELSE or <*FATAL
AY*> or RAISES ANY in turn, hm. 

 A similar problem is when the callback is not passed as parameter but
accessed through a generic module parameter. Then the callback function
may throw exceptions or not and this cannot be handled without warnings.
Example:

GENERIC MODULE IntegerPower(R);

PROCEDURE Power (x: T; y: CARDINAL): T =
....
  pow := R.Mul(pow,pow);
....

where R.Mul can raise exceptions or cannot depending on what we assigned
to R.




 1 Posts in Topic:
Exceptions for call-back functions
Henning Thielemann <ia  2003-10-07 10:22:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 0:35:59 CDT 2008.