Enumerations 
Author Message
 Enumerations


Quote:
> Re: Enumerations in Oberon-2

> Do not forget :

> 1.  Makes all use of enumeration qualified, like the rest of Oberon-2
>     eg. Colour.green, to avoid ambiguity.

This is what was intended.

Quote:
> 2.  As well as MIN and MAX you will need PREV and SUCC.

> 3.  You will need to define what happens if you ask for PREV of MIN
>     or SUCC of MAX.

To avoid introducing new operations, I would suggest that enumerations
work with the existing INC and DEC operations.  If you INC past the MAX
of an enumeration you get an integer (or enumeration) overflow.  Underflow
if you DEC beyond the MIN (always 0) of an enumeration.

Quote:
> 4.  If you export an enumeration type, are all the element names  
>     also exported? (like in fields in a record)

Yes.  Thus you can hide some enumeration values but still have the compiler
have visibility of them since they are always exported with read-only,
read-write, or invisible flags.  Of course, read-write doesn't make sense
but it would be consistent with similar constant declarations.

Quote:
> 5.  How many elements can be in the enumeration list ?

> 6.  What happens if such a list is "Extended" over the MAX
>     range of the underlying variable ?

The base enumeration size would be 16-bits giving a maximum of about 32,000
enumeration values.  This should give plenty of room for any conceivable
enumeration without ever having to change its size.

Mike Griebling



Sun, 06 Apr 1997 18:46:30 GMT  
 Enumerations

Quote:
> >To avoid introducing new operations, I would suggest that enumerations
> > work with the existing INC and DEC operations.  If you INC past the MAX
> >of an enumeration you get an integer (or enumeration) overflow.  Underflow
> >if you DEC beyond the MIN (always 0) of an enumeration.

> This perhaps is not such a good idea, unless you do not allow
> enumeration names to be used.

I'm not sure what you mean.  Is it doing things like:

   INC(enum, e1)    where e1 is an element of the enumeration var enum?

Or do you mean using INC/DEC with enumerations?

Either way, could you expand on why you see a problem?

Quote:
> Taylor Hutt, Grue Hunter

What's a Grue?  I don't think we have any here.

Mike Griebling



Mon, 07 Apr 1997 19:00:31 GMT  
 Enumerations

|>
|> What's a Grue?  I don't think we have any here.

A grue is a mythical creature which featured in the
adventure game Zork. Grues are dark-loving creatures;
Oberon, being such an enlightened language, scares
them all away.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,          | A citizen of NewZealandCorp, a       |
Christchurch, New Zealand          | wholly-owned subsidiary of Japan Inc.|



Tue, 08 Apr 1997 10:02:19 GMT  
 Enumerations

Quote:


>> >To avoid introducing new operations, I would suggest that enumerations
>> > work with the existing INC and DEC operations.  If you INC past the MAX
>> >of an enumeration you get an integer (or enumeration) overflow.  Underflow
>> >if you DEC beyond the MIN (always 0) of an enumeration.

>> This perhaps is not such a good idea, unless you do not allow
>> enumeration names to be used.

>I'm not sure what you mean.  Is it doing things like:

>   INC(enum, e1)    where e1 is an element of the enumeration var enum?

>Or do you mean using INC/DEC with enumerations?

>Either way, could you expand on why you see a problem?

Ok, with normal enumerations and the PREC and SUCC operators, it is
possible to have something like:

TYPE
  enum = (first, second, third, last);

VAR
  x : enum;

  x := PREC(last);

Granted, this type of thing is of limited use, but if you use only INC &
DEC, the semantics are not the same.

  x := DEC(last); ????  

Taylor Hutt, New & Improved
Don't you hate when you can't remember what you were going to say?



Tue, 08 Apr 1997 20:05:14 GMT  
 Enumerations
Re: Enumerations in Oberon-2

Do not forget :

1.  Makes all use of enumeration qualified, like the rest of Oberon-2
    eg. Colour.green, to avoid ambiguity.

2.  As well as MIN and MAX you will need PREV and SUCC.

3.  You will need to define what happens if you ask for PREV of MIN
    or SUCC of MAX.

4.  If you export an enumeration type, are all the element names  
    also exported? (like in fields in a record)

5.  How many elements can be in the enumeration list ?

6.  What happens if such a list is "Extended" over the MAX
    range of the underlying variable ?

Regards Brian Kirk.



Sun, 06 Apr 1997 16:38:26 GMT  
 Enumerations

Quote:


>> Re: Enumerations in Oberon-2

>> Do not forget :

   some of Brian's extremely valid points deleted

Quote:
>> 3.  You will need to define what happens if you ask for PREV of MIN
>>     or SUCC of MAX.

>To avoid introducing new operations, I would suggest that enumerations
>work with the existing INC and DEC operations.  If you INC past the MAX
>of an enumeration you get an integer (or enumeration) overflow.  Underflow
>if you DEC beyond the MIN (always 0) of an enumeration.

This perhaps is not such a good idea, unless you do not allow
enumeration names to be used.

Taylor Hutt, Grue Hunter
Most important creation by Alexander Graham Bell: the _2nd_ telephone.



Mon, 07 Apr 1997 11:02:46 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Follow up on enumerations

2. Eiffel enumerations

3. Reading ActiveX Control Enumerations

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

5. Size of enumerations/subranges in Modula-2

6. Size of enumerations/subranges in Modula-2

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