Re: Clarification on enumerations

I am one of those who agree (and agreed) with Paul that having constraints 
at two levels is messy in the type system.  It's not too bad when doing 
validation of character strings.  It's very difficult if you try to build 
an API that lets programs synthesize documents using values.  Consider an 
integer that's constrained by a regex facet to have exactly two digits, 
the first of which can be a leading zero.  Now, let's assume we've 
invented the obvious Java API for building up the value of this integer:

        item.set(3).

where the signature of set is:

        void set(int)

OK, how do you validate?  Well, one way to do it is to convert the integer 
to canonical form ("3") and decide that it's invalid.  Another is to 
embark on a theorem proving exercise to discover that the representation 
"03" would be perfectly legal.   Of course, if you're always manipulating 
characters, there's no issue, but why have a value space at all then? 
Presumably, it's so that applications can work at the value level when 
desired.  Constraining at two levels is a mess IMO (not without value, 
just a mess.)

------------------------------------------------------------------
Noah Mendelsohn                              Voice: 1-617-693-4036
IBM Corporation                                Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------

Received on Monday, 22 July 2002 20:19:50 UTC