SEDS for ISO 10303-11
Ed Barkmeyer
edbark at nist.gov
Thu Nov 29 13:10:01 EST 2001
Oops! I supported this too soon:
Jochen Haenisch wrote:
> Same for aggregates, but only if they are really assigned a different type
> of aggregate:
> LOCAL
> x : BAG OF INTEGER;
> y: SET OF INTEGER := [1,2,3];
> END_LOCAL;
> x := y;
> In this case TYPEOF(x) should return ['SET', 'BAG'], not only ['BAG'].
NO! In my view, TYPEOF(x) should return ['BAG'].
That is because there are two distinct "occurrences": the variable x and the variable y. The assignment x := y; takes the
value [1, 2, 3] from y, converts it to a value of type BAG OF INTEGER, and assigns the resulting value to x. If subsequently,
we see:
x = x + [1];
the result is [1,2,3,1], because that is what clause 12 says is the interpretation of x + [1].
If you have:
FUNCTION f(x : BAG OF INTEGER);
LOCAL
t : SET OF STRING := TYPEOF(x);
END_LOCAL;
...
END_FUNCTION;
FUNCTION q(...);
LOCAL
x : BAG OF INTEGER;
y: SET OF INTEGER := [1,2,3];
END_LOCAL;
x := f(y);
then the TYPEOF(x) (in f) should return ['SET', 'BAG'], not only ['BAG'].
That is because there is only one occurrence -- the local variable y in q. And that occurrence was of type SET OF INTEGER and
was the actual parameter passed down to TYPEOF.
Now, if in function f, we have:
x := x + [1];
the result should be [1,2,3]. The actual parameter y is substituted for x, the expression x+[1] is then evaluated with that
substitution, being an operation on a SET type (not a BAG type), and the result is assigned to y, an instance of a SET type.
That is, I make a distinction between assignment and substitution, and I only want the "what am I really" behavior to occur for
formal parameters, generalized types and select types. (The latter two explicitly say that the occurrence retains its type.)
> The assignment is the point! Only then the program can really trace the type
> of an instance.
And in so doing, you lose the ability to coerce the value of the instance to a different type.
Put another way, if an assignment retains the type of the right-hand operand, there is no point in declaring types for local
variables. They are always of whatever data type the right-hand operand is interpreted to be. That is a possible and perhaps
better model; but I don't think it is the one Express wants. (And the one I want doesn't have local variables at all! ;-)
-Ed
--
Edward J. Barkmeyer Email: edbark at nist.gov
National Institute of Standards & Technology
Manufacturing Systems Integration Division
100 Bureau Drive, Mail Stop 8260 Tel: +1 301-975-3528
Gaithersburg, MD 20899-8260 FAX: +1 301-975-4482
"The opinions expressed above do not reflect consensus of NIST,
and have not been reviewed by any Government authority."
More information about the wg11
mailing list