Recent Changes - Search:

TypeChecking

(:toc:)

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.

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.

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

  }
}

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
Edit - History - Print - Recent Changes - Search
Page last modified on December 23, 2009, at 08:39 PM