Type Checker<A NAME=6511> </A>

Next: Public Variable Configuration Up: Declaring and Using Previous: Initialization of Public

### Type Checker

You can use a type ckecker procedure to check whether the user has supplied a value of the correct type for a public variable. The type checker is specified in the `-configspec` section of the class declaration after the default value. The following code specifies the type checker procedure `CheckDirection` for the `-direction` variable:

> `-configspec {
> {-direction direction Direction e CheckDirection}
> {-state state State normal}
> }
> ...
> }
> proc CheckDirection {dir} {
> if {[lsearch {n s w e} $dir] != -1} {
> return $dir
> } else {
> error "wrong direction value $
> $"$dir$
> $""
> }`

Notice that no type checker has been specified for the `-state` variable and thus its value will not be checked.

If a type checker procedure is specified for a public variable, this procedure will be called once the value of a public variable is determined by the three steps mentioned above.