I think the key to feeling confident in dynamically typed code is to
go ahead and write out the "contract" for the function in your
comments.  You should always state what the "domain" and the "range"
of the function are, so that you and other people can use the function
appropriately.

A static type system also documents these properties, but you're
restricted to certain concepts that the computer can understand and
prove things about.  You'll start to realize that there are concepts
that are difficult or impossible to easily capture with a static type
system (e.g., this function takes positive even integers, and returns
a number from 0 to 9).

I'm finding Clojure is a bit trickier to write contracts for than
other dynamically-typed languages I've used, because many of the
concepts are somewhat nebulous and don't have good terminology yet
(e.g., this function takes anything that doesn't return an error when
you apply seq to it), but I'd still choose dynamic typing over static
typing any day.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to