jastrachan | 8 Apr 11:07 2005

Re: Eunumeration Type

On 8 Apr 2005, at 09:54, Russel Winder wrote:

> On Fri, 2005-04-08 at 09:46 +0200, Dierk Koenig wrote:
>> Hi,
>> is it planned, to support an enumeration type in
>> the JSR final version?
>> 'enum' is a reserved word, but I guess it's not
>> used yet, right?
>> Any plans in this direction or maybe an own
>> Enum Type, which could well have methods
>> +, -, ++, --, <=>
>> and thus be used within Ranges.
>> Having an isCases() such that enums would work
>> like in Java 5 will be a bit challenging...
> Given that enums are a part of Java 5.0 it would make sense to present
> enums in Groovy with as little extra syntax as possible.

Agreed. Though there's no reason why we can't also add a few extra bit 
of semantics (e.g. enums knowing how to increment/decrement).

def summer = june..august

> Actually this gives rise to a very serious issue for Groovy which we
> have touched on before.
> Is Groovy a JDK 1.4 based system or is it a Java based system?

I'd say Java based, with 1.4 as the baseline.

> If the former then it is a question of reinventing and replicating
> everything in Groovy.  If the latter then it is a question of worrying
> about having backward compatibility for people who are not currently
> using Java 5.0.

Yeah. I don't wanna depend on 5.0 yet.

For enums I think we can just generate Java 1.4 compliant bytecode. 
Though we should be careful we emit Java 5 bytecode for enums & 
annotations etc

> Clearly the generics / annotations / enums / etc. type massive changes
> to the Java language are unlikely to happen in Java 6.0 and Java 7.0 so
> this is probably a one-off sort of problem.

Agreed. I hope there's no major bytecode changes in 6/7 like 
annotations/enums/generics... :)