Chris Zheng <z...@caudate.me> writes: > Hahaha, thanks Philip. Does it really take a doctorate to understand > classification of elephants?
I have a doctorate in how yeast divide. Trust me, computers are easy in comparison to elephants. > I think the overall consensus is that having basic type checking is > good... but over doing types is bad. > > Would this be a reasonable guideline for using types? > > 1. Types are useful for structures that HOLD data (ints, strings, > maps, arrays… ) because they provide ways defining standard > operations to manipulate data that make sense in the context of > that type of data. It is helpful to have a type checker check > that I am not accessing the 6th element of a hashmap or that I am > adding 10 to "Hello". This would be useful indeed. Although, a hard core type head would say "I want to distinguish between a string that is an email, someones name, and a day of the week". This is not unreasonable. > However… I find that I am writing a lot of statements like this: > > (cond (hash-map? v) > …… > > (vector? v) > …… > > (list? v) > ….. > > :else …..) > > I'm not sure a type checker will help in that instance. A type-checker wouldn't no, but a type system would; pretty much every language with a static type system has a type based dispatch somewhere. It would be nice to be able to do (defun fn ([^vector v] ...) ([^list l] ...) ([else] ...) I guess that core.logic will support this at some point. Phil -- -- 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 Note that posts from new members are moderated - please be patient with your first post. 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.