[racket] arity of + versus <=

From: Stephen Bloch (bloch at adelphi.edu)
Date: Fri Oct 28 14:40:13 EDT 2011

On Oct 28, 2011, at 2:28 PM, Joe Marshall wrote:

> On Fri, Oct 28, 2011 at 11:08 AM, Carl Eastlund <cce at ccs.neu.edu> wrote:
>> You seem to be assuming that we have to pick one binary->nary for all
>> binary operators.
> That is the nature of `generalization'.  If I have to discriminate, it isn't
> general.

Quite true.  It would be more elegant if you could write a single "binary->nary" that both made sense and produced something useful for any "reasonable" operator.

So what is the class of "reasonable" operators?  There are several ways to answer this.

One is to pick a notion of generalization, and define "reasonable" to be any operator for which this notion works.

Another, less theoretically elegant but more useful in practice, is to ask actual programmers what operators they would LIKE to be able to generalize, and discard the ones for which you can't come up with a well-defined generalization.

It seems clear that +, *, <, <=, >, >=, and = all have well-defined generalizations that would be useful to practicing programmers.  The fact that they don't all have the same contract, and therefore can't all be generalized in the same way, is unfortunate but unavoidable.

Stephen Bloch
sbloch at adelphi.edu

Posted on the users mailing list.