Fri, 17 Aug 2001 23:45:55 -0400, Dylan Thurston <dpt@math.harvard.edu> pisze:
Here's one cheap proposal:
Add a "MINDEFINITION" pragma which takes a boolean expression whose variables are the class functions. Since it's a pragma, this should only produce warnings if violated.
You mean an expression using && and || and method names? They are indeed enough almost always. In my experience they are not enough only if the default definitions are correct for some uses and incorrect for others, e.g. "foo and bar, and also baz if this is a set rather than a bag" or "succ and pred, and also enumFrom* functions if the type doesn't fit in Int". Since these side conditions are hard to express at all, in these cases the programmer would simply not be warned. I like it, except the name MINDEFINITION, although I tend to call it "minimal definition". REQUIRED? Although "Minimal definition: nothing, all default definitions will make a correct instance" could be spelled by omitting the pragma, an explicit "True" should be allowed too, so one reading the class definition can distinguish between this case and "I didn't bother with specifying what is required". I don't feel a need of having a special shortcut for "all methods must be specified, despite some having default definitions" - just name the methods. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK