![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
The purpose of this post is to outline an alternative to POSSREPS for distinguishing between a type and the physical representation of values of that type on a system. |
|
we can represent any natural number starting from 0 and using the successor operator s as many times as required: 1 is logically represented by s(0) 2 is logically represented by s(s(0)) 3 is logically represented by s(s(s(0))) etc |
|
The following two operators provide two different ways to select geometrical point values snip not-unreasonable explanation of a selector Note that we don't designate some operators as "selectors" and some not. |
#3
| |||
| |||
|
|
On 2011-05-27, David BL <davi... (AT) iinet (DOT) net.au> wrote: The purpose of this post is to outline an alternative to POSSREPS for distinguishing between a type and the physical representation of values of that type on a system. I am beginning to think you are trying to solve a problem that doesn't really exist. |
|
we can represent any natural number starting from 0 and using the successor operator s as many times as required: 1 is logically represented by s(0) 2 is logically represented by s(s(0)) 3 is logically represented by s(s(s(0))) etc Well, so we can, but why do it in this context? You can't go back to first principles in everything every time, not if you want to end up with something usable. |
#4
| |||||||
| |||||||
|
|
On May 29, 8:34 pm, Eric <e... (AT) deptj (DOT) eu> wrote: On 2011-05-27, David BL <davi... (AT) iinet (DOT) net.au> wrote: The purpose of this post is to outline an alternative to POSSREPS for distinguishing between a type and the physical representation of values of that type on a system. I am beginning to think you are trying to solve a problem that doesn't really exist. It's an alternative to possreps. *I think it's neither more nor less powerful. However it's clearly much simpler. I think possreps raise more questions than my proposal. *Here are some off the top of my head after reading Date's Introduction book: 1. Do union types (and particularly dummy types) contradict Date's statement that every type has at least one possible representation? How does it fit in with the claim that the set of values of a given type must be well defined? |
|
2. What are dummy types for? *Can dummy types have subtype relationships declared amongst them? *If so what happens with CONSTRAINT declarations? *Aren't these always required when expressing subtype as specialisation by constraint? |
|
3. Must POSSREPSs have a canonical representation? *What happens if I don't want the selector RATIONAL(numerator,denominator) to have a constraint on the two given integers apart from a nonzero denominator? *What happens if I can much more easily define equivalence than a constraint that forces a canonical representation? Is equality implicitly defined at the logical level? *If so what exactly are the assumptions that allow for the definition of logical equality to be implied? *Alternatively is it up to the implementation to define the equality operator (just like the implementation of any other operator)? |
|
4. Can preconditions be declared on operators? *If so would it be true to say it seems to overlap in purpose with CONSTRAINT declarations? |
|
5. Can additional POSSREPS be added to a type without modifying the original declaration of that type? *Can a new supertype be added to the type system without needing to modify the definitions of all its subtypes? |
|
7. For the types, operators and subtype relationships that comprise a type system, the way in which it is expressed using POSSREPS, dummy types, free standing operators and so forth doesn't appear to be uniquely defined. *Is there a recommended methodology? *What makes one POSSREP more desirable than another? *What is the purpose of defining multiple POSSREPS? *Is it just a way to provide more operators? What's wrong with adding free standing operators instead? *In practise would POSSREPs be expected to provide hints for implementations or is that not really an intention? |
|
8. Is it possible to add super-types to the built-in types? |
#5
| |||||||
| |||||||
|
|
On 30 mei, 08:35, David BL <davi... (AT) iinet (DOT) net.au> wrote: On May 29, 8:34 pm, Eric <e... (AT) deptj (DOT) eu> wrote: On 2011-05-27, David BL <davi... (AT) iinet (DOT) net.au> wrote: The purpose of this post is to outline an alternative to POSSREPS for distinguishing between a type and the physical representation of values of that type on a system. I am beginning to think you are trying to solve a problem that doesn't really exist. It's an alternative to possreps. I think it's neither more nor less powerful. However it's clearly much simpler. I think possreps raise more questions than my proposal. Here are some off the top of my head after reading Date's Introduction book: 1. Do union types (and particularly dummy types) contradict Date's statement that every type has at least one possible representation? How does it fit in with the claim that the set of values of a given type must be well defined? I think it's important to realize that there is a distinction between RM prescriptions, and IM prescriptions. There is "Manifesto _without_ type inheritance", and a "Manifesto _with_ type inheritance", so to speak. RM prescriptions constitute the "Manifesto _without_ type inheritance", and some of them need a great deal of refinement in the "Manifesto _with_ type inheritance". The requirement that "the set of values of a given type must be well-defined" is one such, methinks. Also keep in mind that the inheritance part is not a "required" thing to support for implementations. So all the RM prescriptions are relevant as they are, for an implementation that does not support type inheritance, but for one that does, some of them are superseded by the "refined" versions defined by the IM prescriptions. |
|
2. What are dummy types for? Can dummy types have subtype relationships declared amongst them? If so what happens with CONSTRAINT declarations? Aren't these always required when expressing subtype as specialisation by constraint? If I recall well, dummy types are precisely all the union types that do not have a possrep of their own. If you accept UNION types, then no, CONSTRAINTS are not always needed. A constraint is needed if a type is given, and you want to define a subtype of that type in a predicative way. The type constraint being precisely, your predicate on the given type. A constraint is not needed if two types are given (say, type POINT and type TEMPERATURE), and you want to create the UNION type ('SILLY') of the two. POINT and TEMPERATURE do become a subtype of SILLY, but neither of them 'becomes defined in a predicative way in terms of SILLY'. Both of them remain defined "as they are". |
|
3. Must POSSREPSs have a canonical representation? What happens if I don't want the selector RATIONAL(numerator,denominator) to have a constraint on the two given integers apart from a nonzero denominator? What happens if I can much more easily define equivalence than a constraint that forces a canonical representation? Is equality implicitly defined at the logical level? If so what exactly are the assumptions that allow for the definition of logical equality to be implied? Alternatively is it up to the implementation to define the equality operator (just like the implementation of any other operator)? No comment. The discussion has been had on the TTM discussion list. At quite some length. Nobody changed positions as a result of it. 4. Can preconditions be declared on operators? If so would it be true to say it seems to overlap in purpose with CONSTRAINT declarations? Preconditions such as "the argument value for any LN(FLOAT) invocation must be >=0" ? |
|
D&D's position here can be summarized, I think, as "this issue must be addressed by defining the proper type". (And note that this approach does not require type inheritance ! Even without type inheritance, it is not impossible to define a (distinct) type STRICTLYPOSITIVEFLOAT. If you can _prove_ to them that this approach is unacceptably impractical, please please do !) |
|
5. Can additional POSSREPS be added to a type without modifying the original declaration of that type? Can a new supertype be added to the type system without needing to modify the definitions of all its subtypes? No and No. As for the first "No" : I don't see an impractical difference between "just adding an extra possrep", and "re-issuing the entire type declaration which now includes the extra possrep". As for the second "No" here, this has been discussed on TTM and nobody changed positions. |
|
7. For the types, operators and subtype relationships that comprise a type system, the way in which it is expressed using POSSREPS, dummy types, free standing operators and so forth doesn't appear to be uniquely defined. Is there a recommended methodology? What makes one POSSREP more desirable than another? What is the purpose of defining multiple POSSREPS? Is it just a way to provide more operators? What's wrong with adding free standing operators instead? In practise would POSSREPs be expected to provide hints for implementations or is that not really an intention? Hmmmmmmmmm. The way I see it, types are a "given thing". They are defined by the type implementer (which is the system itself, or the provider of an "external package", or the user itself, or ...), and the TYPE statement is a way to describe its properties. There is no logical difference between THE_ operators that are provided as an inherent part of a type definition, or similar operators that are implemented "independently". But note that in addition to creating THE_ operators, possrep components also create pseudo-variables (and independent operators don't do this) : VAR POINT P := ... ; THE_X(P) := new x coordinate value; THE_THETA(P) := new theta value; As for the "implementation hints" question, I think not, except if the TYPE statement is used by a user as the means for expressing his requirements toward a type implementer, which is not an inconceivable scenario. |
|
8. Is it possible to add super-types to the built-in types? All types are first-class citizens. No distinctions between built-in and user-defined types. |
#6
| ||||||
| ||||||
|
| Is there anything in TTM that prohibits one from making every type a dummy type? *Would that make it essentially the same approach which I've described? |
|
4. Can preconditions be declared on operators? *If so would it be true to say it seems to overlap in purpose with CONSTRAINT declarations? Preconditions such as "the argument value for any LN(FLOAT) invocation must be >=0" ? Yes. *Eiffel uses that term. I think "domain" would be a more conventional term, but the database community has often used 'domain' for 'type'. *I would treat ln(0) as undefined. D&D's position here can be summarized, I think, as "this issue must be addressed by defining the proper type". (And note that this approach does not require type inheritance ! *Even without type inheritance, it is not impossible to define a (distinct) type STRICTLYPOSITIVEFLOAT. *If you can _prove_ to them that this approach is unacceptably impractical, please please do !) I agree it seems impractical, and selectors are treated differently to other operators (only selectors have constraints). |
|
Also, what happens with non-separable constraints on operators with multiple arguments? *E.g. foo(x,y) is defined on x+y > 0. *Is one forced to make it into a unary operator on a type which can express that constraint on its POSSREP? |
|
5. Can additional POSSREPS be added to a type without modifying the original declaration of that type? *Can a new supertype be added to the type system without needing to modify the definitions of all its subtypes? No and No. As for the first "No" : I don't see an impractical difference between "just adding an extra possrep", and "re-issuing the entire type declaration which now includes the extra possrep". As for the second "No" here, this has been discussed on TTM and nobody changed positions. A type system could be so large that these restrictions create difficulties. |
|
8. Is it possible to add super-types to the built-in types? All types are first-class citizens. *No distinctions between built-in and user-defined types. I would say it may be impractical if the answers to Q5 are no. *The built-in types are probably analogous to a third party library which users have no control over. For example, if the system provides a built-in type INTEGER but not RATIONAL, then when someone implements the latter in terms of a pair of INTEGER they also want to declare RATIONAL to be a supertype of INTEGER, so that integers can be passed into all their operators that take RATIONAL. *This is awkward if they have to edit the system provided definition of INTEGER. |
|
From an implementation perspective I cannot see a good reason to outlaw adding supertypes to pre-existing types. *E.g. it is easy to emulate in C++ |
#7
| |||||||||
| |||||||||
|
|
On 31 mei, 11:54, David BL <davi... (AT) iinet (DOT) net.au> wrote: Is there anything in TTM that prohibits one from making every type a dummy type? Would that make it essentially the same approach which I've described? Not "in TTM". What prohibits this is "reality", I'd rather say. If you're interested in a subset of T, then you can't define this subset by means of UNIONs involving T. |
|
And if you're interested in UNIONing things together because that union somehow is of interest to you, then you still must be given some things to union. Somewhere down the line, some non-dummy types must be just given. |
|
I didn't look at the details of your proposed approach because you said yourself that it is neither more nor less powerful than TTM possreps. |
|
4. Can preconditions be declared on operators? If so would it be true to say it seems to overlap in purpose with CONSTRAINT declarations? Preconditions such as "the argument value for any LN(FLOAT) invocation must be >=0" ? Yes. Eiffel uses that term. I think "domain" would be a more conventional term, but the database community has often used 'domain' for 'type'. I would treat ln(0) as undefined. D&D's position here can be summarized, I think, as "this issue must be addressed by defining the proper type". (And note that this approach does not require type inheritance ! Even without type inheritance, it is not impossible to define a (distinct) type STRICTLYPOSITIVEFLOAT. If you can _prove_ to them that this approach is unacceptably impractical, please please do !) I agree it seems impractical, and selectors are treated differently to other operators (only selectors have constraints). Not quite accurate. Selectors do not "have constraints". Possreps do. As a consequence, of course whenever a selector invocation is made, the arguments given must satisfy that constraint, or an exception results. But I don't see how this is different from "non- selector" operators such as LN(FLOAT) ! There too, the arguments effectively passed must satisfy a certain predicate. I find it only a psychological difference that in the case of selectors, the arguments' predicate is declared as part of the construct that gave rise to the existence of the selector operator, whereas in the case of "regular" operators, that predicate is declared in the documentation, or in the metadata, or in the worst case, it is merely implied by the operator's implementing code. |
|
Also, what happens with non-separable constraints on operators with multiple arguments? E.g. foo(x,y) is defined on x+y > 0. Is one forced to make it into a unary operator on a type which can express that constraint on its POSSREP? No, one is not forced to do that. OPERATOR FOO(X INT, Y INT) RETURNS ... ; IF (X+Y)<=0 RAISE ILLEGALARGUMENTEXCEPTION("..."); /* note that dealing with exceptions, or how to raise them, is not part of TTM */ ... END OPERATOR; |
|
5. Can additional POSSREPS be added to a type without modifying the original declaration of that type? Can a new supertype be added to the type system without needing to modify the definitions of all its subtypes? No and No. As for the first "No" : I don't see an impractical difference between "just adding an extra possrep", and "re-issuing the entire type declaration which now includes the extra possrep". As for the second "No" here, this has been discussed on TTM and nobody changed positions. A type system could be so large that these restrictions create difficulties. Completely agreed. But **Tutorial** D is for tutoring purposes exclusively. I've made this mistake dozens of times myself : so beware that you DON'T take certain "properties" of the **Tutorial** D language, to be prescribed properties of the Manifesto **per se**. Other D languages can be totally different from **Tutorial** D, and still be a D (all THAT takes is to conform to the RM (+IM) prescriptions+proscriptions PER SE). (I probably even made this mistake once again where I said that "declaring a UNION type requires re-declaration of the constituent subtypes". This is so in Tutorial D. But I don't think there is an explicit prescription to this effect in the manifesto per se. Mea culpa.) Hence, the freedoms an implementer has to _deviate_ from **Tutorial** D, really go quite far. |
|
8. Is it possible to add super-types to the built-in types? All types are first-class citizens. No distinctions between built-in and user-defined types. I would say it may be impractical if the answers to Q5 are no. The built-in types are probably analogous to a third party library which users have no control over. For example, if the system provides a built-in type INTEGER but not RATIONAL, then when someone implements the latter in terms of a pair of INTEGER they also want to declare RATIONAL to be a supertype of INTEGER, so that integers can be passed into all their operators that take RATIONAL. This is awkward if they have to edit the system provided definition of INTEGER. In the most recent book, "Database Explorations", Date argues that integer numbers are not rational numbers. You should not take the existence of a certain kind of correspondance between the _algebraic structures_ "Z,+,*" and "Q,+,*" (the former is a 'subgroup' of the latter, it is said) to imply that "the members of Z must be a subset of the members of Q". |
|
At any rate, the whole idea is also problematic in that : - if you set up the super/subtype relationship without using a UNION type, then declaring RATIONAL requires the existence of INTEGER (otherwise RATIONAL's possrep cannot be defined), and INTEGER requires the existence of type RATIONAL (_and_ the existence of operators for RATIONAL, otherwise the type constraint for INTEGER in terms of RATIONAL cannot be defined, but that type constraint will have to involve INTEGER factoring, which requires the existence of type INTEGER, etc. etc.) - if you set up the super/subtype relationship by declaring an extra type NONINTEGERRATIONAL (with a constraint that numerator is not a perfect multiple of denominator), and then declare RATIONAL to be a UNION type of INTEGER and NONINTEGERRATIONAL, then you'd still be in trouble once you start defining operators such as rational division, which is not the same operator as integer division, while the IM prescriptions requires, essentially, that operators such as, e.g. "DIVIDE(RATIONAL,RATIONAL)" and "DIVIDE(INT,INT)", are effectively the very same operator if INT is effectively a subtype of RATIONAL. |
|
From an implementation perspective I cannot see a good reason to outlaw adding supertypes to pre-existing types. E.g. it is easy to emulate in C++ Are they "outlawed" ? Did I say that in those words ? |
#8
| |||
| |||
|
|
On Jun 6, 9:26 pm, Erwin <e.sm... (AT) myonline (DOT) be> wrote: On 31 mei, 11:54, David BL <davi... (AT) iinet (DOT) net.au> wrote: Is there anything in TTM that prohibits one from making every type a dummy type? Would that make it essentially the same approach which I've described? Not "in TTM". What prohibits this is "reality", I'd rather say. If you're interested in a subset of T, then you can't define this subset by means of UNIONs involving T. Yes, but that is not a problem. Let Ellipse be a "dummy type". If you're interested in a subtype Circle of Ellipse then you can simply declare Circle as another dummy type. I'm assuming you can declare subtype relationships between dummy types. In my approach you use these declarations: type Ellipse; type Circle; Circle isa Ellipse; I consider types like Circle and Ellipse to be defined by their operators. In that sense there is no problem treating all types as "dummy types". |
#9
| |||
| |||
|
|
David BL wrote: On Jun 6, 9:26 pm, Erwin <e.sm... (AT) myonline (DOT) be> wrote: On 31 mei, 11:54, David BL <davi... (AT) iinet (DOT) net.au> wrote: Is there anything in TTM that prohibits one from making every type a dummy type? Would that make it essentially the same approach which I've described? Not "in TTM". What prohibits this is "reality", I'd rather say. If you're interested in a subset of T, then you can't define this subset by means of UNIONs involving T. Yes, but that is not a problem. Let Ellipse be a "dummy type". If you're interested in a subtype Circle of Ellipse then you can simply declare Circle as another dummy type. I'm assuming you can declare subtype relationships between dummy types. In my approach you use these declarations: type Ellipse; type Circle; Circle isa Ellipse; I consider types like Circle and Ellipse to be defined by their operators. In that sense there is no problem treating all types as "dummy types". Either the operators define the equivalent of possreps or the type model doesn't really describe ellipses and circles. So what are you trying to achieve? |
#10
| |||
| |||
|
|
On Jun 7, 9:49 pm, Bob Badour <b... (AT) badour (DOT) net> wrote: David BL wrote: On Jun 6, 9:26 pm, Erwin <e.sm... (AT) myonline (DOT) be> wrote: On 31 mei, 11:54, David BL <davi... (AT) iinet (DOT) net.au> wrote: Is there anything in TTM that prohibits one from making every type a dummy type? Would that make it essentially the same approach which I've described? Not "in TTM". What prohibits this is "reality", I'd rather say. If you're interested in a subset of T, then you can't define this subset by means of UNIONs involving T. Yes, but that is not a problem. Let Ellipse be a "dummy type". If you're interested in a subtype Circle of Ellipse then you can simply declare Circle as another dummy type. I'm assuming you can declare subtype relationships between dummy types. In my approach you use these declarations: type Ellipse; type Circle; Circle isa Ellipse; I consider types like Circle and Ellipse to be defined by their operators. In that sense there is no problem treating all types as "dummy types". Either the operators define the equivalent of possreps or the type model doesn't really describe ellipses and circles. So what are you trying to achieve? I'm suggesting the operators define the equivalent of possreps. Possreps are redundant. |
![]() |
| Thread Tools | |
| Display Modes | |
| |