View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] Asserts off/on

From: Uwe Zdun <zdun_at_infosys.tuwien.ac.at>
Date: Tue, 11 Jul 2006 18:24:29 +0200

The method "check" can be used to turn off assertions. The example from
the tutorial:

  $fb check all
  if {[catch {$fb set playerRole SINGER} errMsg]} {
    puts "CATCHED EXCEPTION: playerRole has either to be NONE, PLAYER, or TRAINER"
    # turn assertion checking off again and reset to PLAYER
    $fb check {}
    $fb set playerRole PLAYER
  }

The idea is per default all checks are off. Then you turn them on for the objects, you want to be checked in a development environment,
and simply remove the "turn-on code" for the production environment (or redefine the method check, if you want to do it for all methods
at once).


--uwe


Kristoffer Lawson wrote:

> Have I missed something, or is there no easy way of turning asserts
> off or on for all objects? It's common that during the development
> phase you want all the asserts turned on and, perhaps for performance
> reasons, turn them off when finished. I know it could be possible by
> overwriting the create method, or whatever, but I was looking for
> something... well ... less hacky.
>
> / http://www.fishpool.com/~setok/
>
> _______________________________________________
> Xotcl mailing list
> Xotcl_at_alice.wu-wien.ac.at
> http://alice.wu-wien.ac.at/mailman/listinfo/xotcl