Difference between revisions of "Minor-ECMA-problems"
(→Motivation) |
(Restored page content) |
||
(37 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | [[Category:ECMA]] | |
+ | =Precursor= | ||
− | + | The current definition of the Precursor semantics in the ECMA standard (8.10.11) | |
− | + | ||
− | + | =Agent types= | |
− | + | ==Motivation== | |
− | + | The classes ROUTINE, PROCEDURE, FUNCTION and the new class PREDICATE do not nicely fit in to the Eiffel language. Reasons: | |
− | class | + | * They do not reflect the fact, that an agent can refer an attribute. An attribute is not a ROUTINE. |
− | + | * They do contradict the uniform access principle. | |
− | + | * They are difficult to define. It is difficult to understand, why it is so difficult to define an agent type when it is so easy in functional languages! | |
− | + | ** Specially the first generic Parameter of ROUTINE is difficult to understand and, if I am not wrong, never used. | |
− | + | * The standard conformance rules simply do not work nice for agent types. They introduce a type hole that can only be detected at runtime, and even then, only if precondition assertions are enabled. Other than cat calls this typing problem doesn't give the language more power. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ==An other mechanism:== | |
− | + | I will give an example of an other mechanism: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | Instead of writing | |
− | + | ||
− | + | <code>[N, eiffel] | |
− | + | f: FUNCTION [ANY, TUPLE [STRING], INTEGER] | |
− | + | ||
</code> | </code> | ||
− | + | ||
− | <code>[eiffel | + | we could write |
− | + | <code>[N, eiffel] | |
− | + | f (STRING): INTEGER | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Calling this f would be easy: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | i: INTEGER | |
− | + | ... | |
− | + | i := f ("hello") | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | We could also write: | |
− | + | i: INTEGER | |
− | + | ... | |
+ | i := agent f ("hello") | ||
− | |||
− | + | ||
+ | |||
+ | |||
+ | |||
+ | Instead of writing: | ||
+ | |||
+ | f: FUNCTION [ANY, TUPLE [STRING], ANY] | ||
+ | |||
+ | we would write: | ||
+ | |||
+ | f (STRING): ANY | ||
+ | |||
+ | ==Stuff that is not correctly formulated== | ||
+ | Definition 8.5.1 should be changed to something with the following semantics: | ||
+ | |||
+ | ====8.5.1 Definition: Inherited, immediate; origin; redeclared; replicated introduce==== | ||
+ | |||
+ | Any feature f of a class C is of one of the following four kinds: | ||
+ | |||
+ | # If C obtains f from one of its parents, f is an inherited feature of C. In this case any declaration of f in C (adapting the original properties of f for C) is a redeclaration. | ||
+ | # If a declaration appearing in C applies to a feature that is not inherited, the feature is said to be immediate in C. Then C is the origin (short for “class of origin”) of f, and is said to introduce f. | ||
+ | |||
+ | |||
+ | ====8.9.5 Validity: Precondition Export rule==== | ||
+ | A Precondition of a feature r of a class S is valid if and only if every feature f appearing in every | ||
+ | Assertion_clause of its unfolded form u satisfies the following two conditions for every class C to | ||
+ | which r is available: | ||
+ | 1 Iff appears as feature of a call in u or any of its subexpressions, f is available to C. |
Latest revision as of 10:12, 30 May 2007
Contents
Precursor
The current definition of the Precursor semantics in the ECMA standard (8.10.11)
Agent types
Motivation
The classes ROUTINE, PROCEDURE, FUNCTION and the new class PREDICATE do not nicely fit in to the Eiffel language. Reasons:
- They do not reflect the fact, that an agent can refer an attribute. An attribute is not a ROUTINE.
- They do contradict the uniform access principle.
- They are difficult to define. It is difficult to understand, why it is so difficult to define an agent type when it is so easy in functional languages!
- Specially the first generic Parameter of ROUTINE is difficult to understand and, if I am not wrong, never used.
- The standard conformance rules simply do not work nice for agent types. They introduce a type hole that can only be detected at runtime, and even then, only if precondition assertions are enabled. Other than cat calls this typing problem doesn't give the language more power.
An other mechanism:
I will give an example of an other mechanism:
Instead of writing
f: FUNCTION [ANY, TUPLE [STRING], INTEGER]
we could write
f (STRING): INTEGER
Calling this f would be easy:
i: INTEGER ... i := f ("hello")
We could also write:
i: INTEGER ... i := agent f ("hello")
Instead of writing:
f: FUNCTION [ANY, TUPLE [STRING], ANY]
we would write:
f (STRING): ANY
Stuff that is not correctly formulated
Definition 8.5.1 should be changed to something with the following semantics:
8.5.1 Definition: Inherited, immediate; origin; redeclared; replicated introduce
Any feature f of a class C is of one of the following four kinds:
- If C obtains f from one of its parents, f is an inherited feature of C. In this case any declaration of f in C (adapting the original properties of f for C) is a redeclaration.
- If a declaration appearing in C applies to a feature that is not inherited, the feature is said to be immediate in C. Then C is the origin (short for “class of origin”) of f, and is said to introduce f.
8.9.5 Validity: Precondition Export rule
A Precondition of a feature r of a class S is valid if and only if every feature f appearing in every Assertion_clause of its unfolded form u satisfies the following two conditions for every class C to which r is available: 1 Iff appears as feature of a call in u or any of its subexpressions, f is available to C.