Re:Ask HN: Has Hacker News been hacked/cracked?
by pg on Tuesday March 17, 2009 @08:10PM
(#520867)
It's an interesting question whether it's really a type error to mismatch the sizes of things. I feel like sometimes it is and sometimes it isn't.
[ Parent
| on HN ]
Re:Ask HN: Has Hacker News been hacked/cracked?
by KayEss on Wednesday March 18, 2009 @01:30AM
(#521252)
In a strongly typed language one would normally want to reify the number in the type system whenever possible, i.e. the use of (a,b,c,d,e) rather than [a,b,c,d,e] in Haskell (that's a 5-tuple rather than a 5 element list).
I think that people used to dynamic programming languages would normally pick the list rather than the tuple simply because it at first appears easier. I think Dijkstra had something to say on that particular subject :)
Re:Ask HN: Has Hacker News been hacked/cracked?
by jganetsk on Wednesday March 18, 2009 @12:18AM
(#521178)
Agreed. But it sounded like, in this case, you were using a list to represent that which would have been represented by a record in a statically typed language.
I'm imagining you'd have some kind of Field record type, with isDisplayable and isModifyable fields. Instead of destructuring as a list (or tuple), you would explicitly look for isDisplayable and isModifyable.
But, of course, you could still make the same mistake in a statically typed language if you chose not to set up the data structure this way.