Mike Austin's Blog

Monday, November 27, 2006

Optional typechecking

Steve had a quote about type inference on his blog and it reminded me of something. I seem to always come back to Dylan when looking for good ways to do something. Like optional (runtime) typechecking...

In Dylan, you can write a strict version, which checks the argument and the return type:
define method double (thing :: <number>)
=> another-thing :: <number>;
thing + thing;
end method;
Or leave it completely open:
define method double (thing)
thing + thing;
end method;
Sometimes you don't care what kind of argument you get, you just pass it on. But sometimes you do, and it's nice when the system can tell you exactly where you went wrong.