Follow up on enumerations 
Author Message
 Follow up on enumerations

Quote:
>: The lack of an enumerated type facility in Eiffel can be a serious
>: problem with "similar" types. The use of names of INTEGER values to specify
>: different, essentially hardcoded, values is only slightly better then
>: using the actual integer values themselves in some cases.
>: For example, if two methods take predefined INTEGER values as parameters
>: to invoke different behaviour things can get confusing. Say parameter X takes
>: OPTION_A or OPTION_B, while parameter Y can be OPTION_1 or OPTION_2.
>: Eiffel allows improperly mixing of these parameters (passing OPTION_1 for X
>: and OPTION_B to Y) which can lead to confusing code & behaviour.
>: A simple way to avoid this is to add an enumerated type facility so that
>: X & Y can be declared of different types, in which case the above error
>: would be caught at compile time.
>Uh you mean something like:
>class LETTERED_OPTIONS is
>    feature
>         datum:INTEGER
>        -- add routines to return '.a' and '.b'
>end;
>class NUMBERED_OPTIONS is
>        feature
>           datum:INTEGER
>      -- add routines to return '.one' and '.two' or whatever.
>end

Without seeing your ideas for .a, .b, .one and so on I can't
comment on the workaround you propose in its entirety, but for
starters:

i) how are these things created/set?
For EXPANDED, we can't use more then one creator, nor can we use
arguments to the sole creator, and if a "set" feature takes an
INTEGER (i.e. if a, one are INTEGER) then there is little added value.

ii) does "out" print anything meaningful by default, or does it have
to be rewritten for every class?

iii) how are these things examined?
If you are proposing accessing datum as an INTEGER, then I don't see
much added safety (some, but not enough).

iv) how much overhead is anticipated, both storage and CPU?

v) how would these classes work as indices (keys) for collections?

Please provide a more complete example and we can discuss it further.



Mon, 29 Dec 1997 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Eiffel enumerations

2. Reading ActiveX Control Enumerations

3. Fanaticism [was Re: Enumerations and Arrays Unnecessary!???]

4. Size of enumerations/subranges in Modula-2

5. Size of enumerations/subranges in Modula-2

6. Enumerations

7. enumerations

8. Enumerations - slow down a minute!

9. Enumerations in Eiffel

10. Pattern for enumerations? (Attn: Roger Browne)

11. Enumerations in Oberon (was: Re: Enumerated types)

12. enumerations

 

 
Powered by phpBB® Forum Software