Re: Named Integers

From: Douglas G. Danforth <"Douglas>
Date: Sat, 20 Nov 2004 20:39:04 -0500

----boundary-LibPST-iamunique-380171959_-_-
Content-type: text/plain

Stan,
I like the idea of Named Integers. They would indeed simplify the
documentation (now, what possible problems could they cause?).
-Doug

Stan Warford wrote:
> The benefit of named integers is self-documentation. On the surface,
> they look like enumerated types, but they are fundamentally different
> because they do not have the implementation problems of type
> checking that enumerated types have. Hence, you get 90% of the
> benefits of enumerated types with 10% of the implementation cost.
>
> Here is an example. In the documentation for Module Ports, we have
>
> CONST
> invert = 0; hilite = 1; dim25 = 2; dim50 = 3; dim75 = 4;
>
> Then, later in the documentation we have
>
> (f: Frame) MarkRect (l, t, r, b, s: INTEGER; mode: INTEGER; show:
> BOOLEAN), NEW;
>
> Then, still later in the documentation, we have this explanation
>
> CONST invert, hilite, dim25, dim50, dim75
> These values may be passed as mode-parameter to procedure MarkRect.
>
> The parameter list of MarkRect is _not_ self-documenting. All you know
> by looking at formal parameter mode is that it is an integer. All you know
> by looking at the CONST section is that there are some integer constants,
> but you have no way of knowing which of the integer constants, if any,
> is meant to be used as the mode value in MarkRect. You must search through
> the documentation for the explanation.
>
> Named integers would work like this.
>
> TYPE
> MarkMode = (invert, hilite, dim25, dim50, dim75);
>
> (f: Frame) MarkRect (l, t, r, b, s: INTEGER; mode: MarkMode; show:
> BOOLEAN), NEW;
>
> Although the syntax looks like the syntax of enumerated types, named
> integers are _not_ enumerated types. As I understand it, 90% of the
> difficulty of implementing enumerated types is the type checking that must
> occur across modules. The implementation difficulty was so severe that
> enumerated types were not included in the definition of CP.
>
> Named integers have none of the implementation problems of enumerated
> types. They are simply a syntactic sugar that provide an immense benefit
> of self-documentation for a very small price. They do not introduce a new
> type. Named integers _are_ integers. In general
>
> TYPE Alpha = (beta, gamma, delta);
>
> is _defined_ to be exactly equivalent to
>
> TYPE Alpha = INTEGER;
> CONST beta = 0; gamma = 1; delta = 2;
>
> As far as export is concerned
>
> TYPE Alpha* = (beta, gamma, delta);
>
> is defined to be equivalent to
>
> TYPE Alpha* = INTEGER;
> CONST beta* = 0; gamma* = 1; delta* = 2;
>
> There is no need for complex type-checking rules with enumerated values
> as there is in C++. gamma _is_ an INTEGER and can be used anywhere an
> integer can be used. mode is still an INTEGER. Named integers would change
> _nothing_ in the implementation of the entire BlackBox framework except for
> making the interfaces much easier to read.
>
> When I was first learning the BB framework I was used to software design
> that emphasized enumerated types for self-documentation. It was a source
> of irritation to see an integer parameter in a formal parameter list and
> not
> know immediately which set of integer constants applied to it. I think one
> reason it has been a hard sell to the folks at Oberon microsystems is that
> they are so familiar with the framework that they forget what it is like
> for
> a novice to be learning BB for the first time.
>
> 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-380171959_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwX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BzZXJ2ZXIgd2lsbCByZWNvZ25pemUgeW91IGFzIHN1YnNjcmliZXIgYW5k
IGZvcndhcmQgeW91ciBwb3N0aW5nIGltbWVkaWF0ZWx5LCB3aXRob3V0IGNyZWF0aW5nIGFueSBv
dmVyaGVhZC5ccGFyDQpccGFyDQpiKSBJZiwgZm9yIHNvbWUgcmVhc29uLCB5b3UgY2Fubm90IHBv
c3QgZnJvbSB0aGUgYWRkcmVzcywgYnkgd2hpY2ggeW91IGFyZSBzdWJzY3JpYmVkLCB5b3VyIG1l
c3NhZ2Ugd2lsbCBiZSBtb2RlcmF0ZWQgdG8gYXZvaWQgc3BhbS4gUGxlYXNlIHVuZGVyc3RhbmQg
dGhhdCBtb2RlcmF0aW9uIHdpbGwgb2Z0ZW4gY2F1c2Ugc29tZSBkZWxheSwgaW4gcGFydGljdWxh
ciBvdmVyIHdlZWtlbmRzIG9yIGhvbHlkYXl9fQAsIGIsIHM=


----boundary-LibPST-iamunique-380171959_-_---
Received on Sun Nov 21 2004 - 02:39:04 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:28:30 UTC