----boundary-LibPST-iamunique-1689799210_-_-
Content-type: text/plain
Hi Stan
Sorry for the confusion. I should have explained myself better.
I have to admit further that I don't see the difference to C style enums
clearly.
Problem 1:
TYPE
Colour1* = (blue, red);
Colour2 = (red, blue);
Above we have two times 'red' and 'blue' with different values assigned. If
expanded it would result in:
CONST
red = 0;
red* = 1;
blue* = 0;
blue = 1;
and wouldn't compile.
To solve this problem they would need to be put in there own namespace.
An adapted C# (Java 1.5.0) style notation would probably look like:
* within a module: Colour1.blue;
* outside a module: Module.Colour1.blue
Problem 2:
Let's assume an application has been produced and deployed:
TYPE
Colour* = (blue, red);
(* red = 2 *)
and years later changed to:
TYPE
Colour* = (blue, orange, red);
(* red = 3 *)
The problem here is that 'red' changed in the production code to 3. If other
modules depend on it they would need to be re-compiled. (A CONST red = 2; is
unlikely to be changed by accident.)
Serialization of data and networking would add further to the above problem.
(transmitting a '3' instead of a '2' and producing a car in the wrong colour
:-)
A compiler could issue a warning if a value had changed position.
********************************
Offsets in enums are a very useful in low-level programming:
TYPE
Flags = {rx: 2, overflow, frameError, tx: 12, reserved: 13..31};
(* Flags is of type SET, rx is the 3rd bit in Flags etc. so the same
as CONST rx = 2; reserved is a SET itself an therefore a problem... *)
Maybe a better notation:
TYPE
Flags = {rx: 2, overflow, frameError, tx: 12}: SET;
Int = {zero, one, three := 3}: INTEGER;
...
IF Flags.overflow IN Flags THEN...
********************************
Another form of notation could be (C bit struct):
TYPE
Cpu = RECORD [SET]
flagA: 0; (* Should it be an integer or a SET? *)
flagB: 1;
unused: 2..30; (* problem: What type? SET? See below *)
flagC: 31;
END;
Current implementation:
If [INTEGER] IN [SET] THEN
Additionally required:
IF [SET] IN [SET] THEN (* would work *)
Well, I guess I should stop here :-)
Cheers,
Philipp
-----Original Message-----
From: Stan Warford [mailto:Stan.Warford{([at]})nowhere.xy
Sent: Monday, 22 November 2004 11:01 a.m.
To: Hof, Philipp
Cc: 'blackbox{([at]})nowhere.xy
Subject: Re: Named Integers
On Nov 21, 2004, at 12:51 PM, Hof, Philipp wrote:
>> now, what possible problems could they cause?
>
> Just some hurry thoughts:
>
> *******************************************
>
> Problem 1:
>
> TYPE
> Colour* = (red := 3, blue, green);
> CarColour* = (blue, yellow, orange);
>
> If I understand the idea right this would be identical to:
>
> CONST
> ...
> blue* = 4;
> blue* = 1;
I see little use for this complicating feature and
would not allow it. All named integers would
start at 0, and increase sequentially by 1.
> *******************************************
>
> Problem 2:
>
> TYPE
> Colour* = (red = 3, blue, green);
> (* green = 5 *)
>
> changes to:
>
> TYPE
> Colour* = (red = 3, blue, lightBlue, green);
> (* green = 6 *)
>
> -> Causes a problem to existing (compiled) modules using 'Colour'
>
> *******************************************
Same comment applies. Do not supply that
feature. There are many instances where
named integers would be a big improvement,
and only relatively few that would benefit
from relaxing the restriction that they all
start at 0 and increment by 1.
Keep it simple.
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-1689799210_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7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