----boundary-LibPST-iamunique-1468555678_-_-
Content-type: text/plain
On Nov 21, 2004, at 6:49 PM, Hof, Philipp wrote:
> 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.
Right. It would not 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
I would not solve the problem by making namespace rules.
Keep it simple and let it not compile. The programmer can
always use consistent prefixes or postfixes in the identifiers
if it is necessary to have more than one "blue", e.g. xBlue, yBlue.
> 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.)
Yes. So let it be recompiled. That is what always happens when you
change the interface of a server module.
[snip]
> 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...
Well, these uses of enum are different from the uses that named
integers are designed for. Named integers are simple syntactic
sugar that fix a common problem in the BB documentation. Namely
the interfaces are not self-documenting. There are many examples
of the problem in the BB documentation. It was quite easy to find the
Ports example. There are very few examples in the documentation
(or in high-level programming as opposed to low-level programming)
of the problems you are raising here. I see your point. The issue,
however, is not just how to come up with a feature to solve a problem.
The issue is also the frequency of the problem in practice. Named
integers solve a common problem with a minimum implementation cost.
[snip]
Thanks for the comment.
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-1468555678_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIE9uIE5vdiAyMSwgMjAwNCwgYXQgNjo0OSBQTSwg
SG9mLCBQaGlsaXBwIHdyb3RlOlxwYXINClxwYXINCj4gSGkgU3RhblxwYXINCj5ccGFyDQo+IFNv
cnJ5IGZvciB0aGUgY29uZnVzaW9uLiBJIHNob3VsZCBoYXZl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