----boundary-LibPST-iamunique-1452500437_-_-
Content-type: text/plain
>> of the problem in practice. Named integers solve a common
>> problem with a minimum implementation cost.
>
> That depends on their *complete* definition. The fact that they are a
> named type means there are additional considerations compared to the
> used of CONSTs that have not been mentioned.
I think their complete definition is give by the specification:
TYPE Alpha = (beta, gamma, delta);
is equivalent to
TYPE Alpha = INTEGER;
CONST beta = 0; gamma = 1; delta = 2;
and
TYPE Alpha* = (beta, gamma, delta);
is equivalent to
TYPE Alpha* = INTEGER;
CONST beta* = 0; gamma* = 1; delta* = 2;
That is all. Nothing else. No changing the start value, no skipping
values or assigning arbitrary values in the middle, no range checking,
no special scope rules for the identifiers.
Keep it simple.
> There are a number of
> questions that need to be addressed. These include but are not limited
> to:
>
> 1. What are the compatibility rules of named integers with other
> ordinal
> types?
>
> VAR
> c: Colour;
>
> Is c := 1 acceptable?
The specification says "yes". c:= 1 is acceptable.
c is an INTEGER. The specification does not prevent
the programmer from misusing the feature.
> 2. What are the compatibility rules of a variable of one type of named
> integers with another? For example, Given:
>
> TYPE
> Colour = (green, orange, yellow);
> Fruit = (fApple, fOrange, fBanana);
>
> VAR
> c: Colour;
> fruit: Fruit;
> ...
> ...
>
> does
>
> fruit := orange;
>
> result in an error?
The specification says "no", fruit := orange does not result in an
error.
fruit is an integer. orange is an integer constant. The specification
does
not prevent the programmer from writing badly documented code.
> 3. Can named integers be used wherever integers can be used.
Yes. Named integers _are_ integers.
> Fore
> example, does the INC function accept a named integer as a parameter?
Yes. Named integers _are_ integers.
> If
> yes and Colour is a named integer type:
>
> TYPE
> Colour = (red, yellow, blue);
>
> VAR
> c: Colour;
>
> What is the result of:
>
> c := blue;
> c := INC(c);
Postcondition is c = 3.
> etc. etc.
How many more etc.'s do you wish too enquire about?
They are all handled by the specification.
> These are just a few that I thought of, off the top of my head.
>
> Before responding to each issue, I recommend that you go through the
> actual exercise of modifying the Language Report thoroughly to
> accommodate the proposed feature of Named Integers and then reconsider
> whether the implementation cost would be minimal.
I have done that. I challenge anyone to come up with a problematic
scenario that is not handled by the specification.
> I haven't tried it
> myself, but I suspect that the corresponding effort would not be
> significantly less than actually implementing an 'enumerated type'
> feature.
But that suspicion is countered by the fact that enumerated types
were rejected by the designers of CP because of implementation
difficulties. Similarly, range types from Pascal were rejected. You
could define a type
Year = 1800..2050;
that is an integer with range checking. Your example c := INC(c)
was probably motivated with range checking in mind.
My point is that programmers are so used to having _all_ of the
features of enumerated types or, in the case of CP, _none_ of
the features of enumerated types, that nobody considers named
integers as a compromise. Named integers would be a trivial
implementation for the compiler writers, but would provide the
valuable feature of self-documentation. It does not force the
programmer to write good self-documenting code, but it makes
it easy for the programmer to do so with virtually no added
complexity to the type system of the language. It is convenient
syntax that, unlike enumerated types, has _no_ impact on the
type semantics of the language.
Cheers,
Stan
J. Stanley Warford
Professor of Computer Science
Pepperdine University
Malibu, CA 90263
Stan.Warford{([at]})nowhere.xy
310-506-4332
--------------------------------------------
To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
blackbox-request{([at]})nowhere.xy
To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.
Send any problem reports or questions related to this email list to the list owner at
owner-blackbox{([at]})nowhere.xy
Current posting policy:
a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.
b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.
----boundary-LibPST-iamunique-1452500437_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MC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