On 14/08/2012, at 4:43 PM, Dobes Vandermeer wrote: > > So ... explain your approach to lists and graphs of heterogeneous objects > (loaded from a file, say) that doesn't suck ...
It's impossible in principle, theory, and practice. Its a design error. Your brain is screwed. You cannot have a heterogenous list. Its nonsense. So fix your bad design. Fix you brain. Find a way to make the list homogeneous. There are a number of ways to do this. The obvious one in most functional languages (Ocaml, Haskel, Felix) is to use a union type. However some kind of subtyping or polymophism may be possible as well, if the objects in the list are, say, all shapes which need to be drawn. What SUCKS totally is the Java approach: a list of "object" where you have to do a cast to one type or another. This is totally fragile. There are no assurances anything will work properly. Unions do have issues, such as the fact ordinary ones are a fixed closed set, which makes extensions hard to deal with because you have to rewrite every place you decode the union. That happens in Felix. Every time I add a new type or value term I have to add a case to 20 different places in the compiler. Is that a design fault using unions? That makes them suck! NO NO NO! Its not. Its correct. i really DO have to account for the new term in 20 different places. There's no work around or general shortcut. At best, you might use say Ocaml polymorphic variants to factor unions. Ordinary unions cannot be factored as data types, they have to be factored in your matches by control paths. Polymorphic variants in Ocaml allow factoring to group cases. My point is .. it sucks. Because it sucks. you cannot fix it. you can only make it WORSE by using dynamic typing. The only advantage you get from dynamic typing is that you can get parts of the code working first, then others, which is harder to do with static typing (where everything has to type check before you can test anything). There are always parts of all programs which are dynamic. The point is to make as much strongly and statically typed as makes sense, and restrict the dynamics as much as possible. Felix is intended to be dynamically typed. But there dynamics won't be added until we've exhausted the expressivity and power of advanced static typing technology (or as much as the developers can understand :) -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language