
On 13 October 2011 10:12, Christian Maeder
Why do most people like duplicate or repeated code?
Hi Christian, I can't speak for most people, but I like my data types to encode the semantics of the domain. In this case, the connectives are logical devices that allow the formation of new well-formed formulae from old ones. I also think it's a mistake to consider them, in their guise as operators, to be any different from negation save in their arity. In my code they are on a par, and any extension to include new n-ary connectives would be straightforward and natural. (There are other unary and binary logical operators which happen not to be listed; I simply included the most commonly used ones, rather than add NAND, XOR, etc. As Daniel pointed out, merely including negation and disjunction allows the formation of a truth-functionally complete system. One can also do this with just NAND or NOR.) The duplication is, ultimately, fairly minor, so doing what you suggest also seems like overkill: it's not as though I'm going to be adding another five or ten connectives any time soon. Your version, while admittedly shorter, makes the code more complex and less readable, for no gain in expressiveness and a very minor improvement in brevity. Benedict