layout: post
title: Type checking
-

{{ page.title }}

7 November 2011

Most scripting languages do not perform type checking during compilation,

However PERL goes the middle ground; one can enable STRICT mode; in strict mode the following situations are compilation errors; without STRICT mode these errors are runtime errors.

I think that this is a very useful feature; fixing these errors during compilation is easier then debugging the program and looking for them while debugging the program.

Now Perl is sort of unique among scripting languages in that it can enforce some typing very easily; each variable has its type as prefix , $sc here sc is a scalar $v[i] here v is a vector and $vv{ ‘aa’ } vv is a hash. When type is not part of variable name, then you have to do some type inference in order to implement this feature;

Of course we can’t have full type checking; this is a scripting language, after all.
If a variable is inserted into a collection (array or hash table) and later retrieved from the collection, then its type can only be checked during run time.

Anyhow for the Pooh scripting language we are going to implement a limited form of type checking.