by algolicious · 14y ago · 0 comments
I must say that the lack of static typing really gets in the way on larger projects. Being able to confidently change datatypes and function signatures, knowing that the compiler will point out most inconsistencies that you introduce, is something that I've really come to appreciate after working with Rust and Haskell. Test coverage helps, of course, but I'm not a very diligent test writer, and tend to feel that type signatures are easier to maintain than an exhaustive test suite.
I haven't had the chance to try this out yet. I'm sure some people like the fact that their programming language won't put up with fast-and-loose code -- you probably don't want your workout buddy to agree too eagerly to your suggestion that you skip the gym and grab a milkshake instead. But I think it might work for me. I'd be interested to hear about people's experiences, at any rate.
/**
* @param {Function} fn
* @param {string|null|undefined} str
*/
foo.bar = function(fn, str) {
// do something
}
It is pretty powerful, you can also do some generics-like stuff like "@param {Array.<string>}" to enforce an array with only strings as elements.It's kind of shame Dylan died out. It seems like it was ahead of its time in many ways.
It checks both at compile time and at run time. I find it great for bug squashing. See http://www.sbcl.org/manual/index.html#Declarations-as-Assert...