Wize /
Type Checking
Search:  

1.  Type Checking

Wize provides two levels of typechecking.

It provides Validation when an application is run with wize -Wall to perform static checking of all code in the application.

But it also can provide runtime type checking.

2.  Runtime Command Checking

Runtime argument checking can be enabled on a proc using [info checking]:

  proc foo {a} { #TYPES: Int Double

  }

  info checking foo 1
  foo XX

In this case, the call foo XX will result in a runtime error because XX is not a double.

3.  Checking In Namespaces

Checking can also be enabled by default for all procs created in a namespace, eg:


namespace eval ::app

  info checking -namespace ::app 1


  proc foo {a} { #TYPES: Int Double

  }
}

4.  Return Values

Return values are also checked: ie. a mismatched return value will cause an error, eg:

  proc foo {a} { #TYPES: Int Double
     return X
  }

  info checking foo 1

© 2008 Peter MacDonald

Page last modified on December 23, 2009, at 08:39 PM