home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 488.lha / TCL_alpha2 / tcl.lzh / tcl / docs / tcla / panic.doc < prev    next >
Encoding:
Text File  |  1990-05-04  |  2.4 KB  |  54 lines

  1.  
  2.  
  3. Tcla can panic.
  4.  
  5. This means that Tcla can encounter a situation that it can't recover from.
  6. For example, it might detect corruption of one of its linked lists, be
  7. unable to create a port, or detect some other error condition or get to
  8. somewhere where it was expedient for Tcl to "throw up its hands."
  9.  
  10. If Tcla panics, by default it will display a requester that makes some
  11. explanation of what the problem was, where the "continue" and "cancel"
  12. options instead both say "panic."  
  13.  
  14. After the user clicks on one of the panic gadgets, panic continues by 
  15. calling a user-specified cleanup routine, if one has been specified.
  16. The user-specified routine can perform cleanup operations, including
  17. calling Tcl_DeleteInterpreter, which will cause Tcla to perform all
  18. of its cleanup.  The user cleanup routine should then call exit, _exit,
  19. Exit or whatever.  (So far, we have found that it is safe to go ahead
  20. and call Tcl_DeleteInterp after a panic)
  21.  
  22. There are Tcla calls that allow the user to specify three special "upcall" 
  23. routines for use by Tcla.  These are routines that you specify that Tcl
  24. can call when it gets into trouble.  One, Tcla_CleanupRoutine, allows the 
  25. user to specify a cleanup routine that panic will call.  The second, 
  26. Tcla_PanicRoutine, allows the user to replace the default panic behavior 
  27. with one of their own choosing.  When your panic routine is called, it 
  28. receives an argument of "char *" containing the panic text.  This routine 
  29. must take a standard Aztec C call (Lattice may work); that is, it must not 
  30. have a #pragma defined that causes it to expect or return arguments in 
  31. registers.
  32.  
  33.     void 
  34.     Tcla_CleanupRoutine(struct TclaHeader *TclaHead, 
  35.         void (*cleanup_routine)(void));
  36.  
  37.     void 
  38.     Tcla_PanicRoutine(struct TclaHeader *TclaHead, 
  39.         void (*panic_routine)(char *));
  40.  
  41.     void Tcla_LowMemRoutine(struct TclaHeader *TclaHead, 
  42.         int (*lowmem_routine)(long));
  43.  
  44. The user-routine specified by Tcla_LowMemRoutine is called by Tcla if it
  45. is unable to allocate some memory it has requested.  An argument to the
  46. routine is the long int number of bytes requested.  The routine is to
  47. return a zero if Tcla is to go ahead and retry the memory allocation
  48. (presumably the user routine has freed some memory), or a nonzero to
  49. indicate that Tcla is to go ahead and panic.  (A zero value was used to
  50. mean that the allocation is to be retried to prevent a garbaged 
  51. argument from causing an infinitie loop while trying to allocate and
  52. continuously failing.)
  53.  
  54.