in reply to Re: Static checking
in thread Static checking

I may be totally wrong, but I always thought that the advantage of static typing had mostly to do with speed and size.

Those are often advantages to a type system, but it's also a debugging aid. In your Perl example, what happens if $thing is a simple scalar instead of a blessed reference? Or what if it is an object, but that object doesn't implement a to_xml method? In Perl5, you won't know these things until runtime. Whereas with the C++ example, the compiler will complain if thing isn't a bar instance.

Though the C/C++ type system is broken in some ways which hurt debugging, which is covered in Dominus' Strong Typing talk (noted earlier in this thread).

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated