Re:Ask YC: Ruby and Lisp devs, please answer this (Not a fla...
by jfoutz on Monday January 14, 2008 @08:28PM
(#98450)
This is a little tricky, Types can be pretty broad. First, you could define a tree type with all sorts of different leaves, you could have a list of tree parts, something like:
Tree = Branch Tree Tree | ILeaf Int | SLeaf String
then a list like [ILeaf 1, SLeaf "foo"]. Another way to go takes advantage of type erasure. Currently it's just a popular extension but it lets you have lists of stuff in the same type class.
A good example is "Show" you can have a list off stuff that knows how to turn itself into strings. always a handy thing.
Basically you get the big two, group things based on what they are, or group things based on what you can do to them.
Perhaps there is a big pile of random stuff you want to hang on to, but i'd bet 99.9% of the time you really want to collect the stuff into a coherent type.
In a similar vein, I wonder about the Erlang hype - some things are really impractical to do in Erlang, for lack of syntactic sugar and the immutable memory constraint. People were always bickering about the constraints in Java (no multiple inheritance and stuff like that), so why choose another language with impractical constraints instead?