Re: domains aren't subtypes, right?
Date: 25 May 2003 11:23:53 -0700
Message-ID: <e4330f45.0305251023.55e73ab7_at_posting.google.com>
"Bob Badour" <bbadour_at_golden.net> wrote in message news:<mrsza.221$mc1.67692577_at_mantis.golden.net>...
> > > So what is the relationship of the city type to the string type? It's
> > > not a subtype.
> >
> > It is. I don't see any problem. We simply must decide which operators
> > we want to inherit.
>
> Alfredo, I have to disagree with your above statement.
Well, after thinking a bit and reviewing TTM, I also disagree with myself O:-)
Thanks for the clarification.
> If it is a subtype,
> it inherits all value operations.
Not all. It only inherits all the read only operators, but not all update operators.
See TTM pages 306-307.
> In the specific example given, "string" is merely a possible representation
> of the city type. City might be a subtype of location or of geographic area,
> for instance, but it is not a subtype of string.
But City is usually only a shorthand for city_name. And city_name's type may be a subtype of string.
var Addresses real relation { ..., City Char(20), ...
If we concat two city_names we will get a new string value which might be part of the city_name's type or not.
type CityNameType is Char(20);
var a char;
var b CityNameType;
var c CityNameType;
b := 'asdfghjkl';
c := 'qwertyuiop';
a := b || c;
Is_CityNameType(a); // True
a := b || c || b;
Is_CityNameType(a); // False
Another example:
Type CN is char constraint (CN in ['London', 'Rome', 'Madrid', ...
var a char;
var b CN; var c CN; var d CN;
...
a := b || c; // will work always
d := b || c; // will fail always if there is not any city with a name like Romelondon :-)
We would need a very smart compiler in order to get such errors at compile time.
> > For instance we probably don't want to have a focus_distance operator
> > in a circle type.
>
> Why not?
Only when focus_distance is an update operator.
Regards
Alfredo
Received on Sun May 25 2003 - 20:23:53 CEST