by nwhitehead · 13y ago · 0 comments
I absolutely hate the idea of "valueOf". Why would you ever in your life want to add together tuple values by default? It's a misfeature that is begging to cause bugs. A better feature would be some way of applying functions across tuples of the same size (map and fold type operations) to make it easy to build up correct comparison functions.
Does that sound saner? It is definitely simpler and a lot closer to an actual tuple implementation.
I want to turn this into a small repository so maybe I will take the little good bits and drop anything unnecessary.
function Tuple(/* args... */) {
var args = arguments;
this.unpack = function(fn) {
return fn.apply(null, args);
}
}You are just relying on your users to not abuse _ prefixed variables. It's far from ideal.