PROPOSAL: Abstract enums (version 2)
Howard Lovatt
howard.lovatt at iee.org
Tue May 12 17:35:17 PDT 2009
On a pragmatic point, I doubt if the proposal will go anywhere since
no one is supporting it except me :( The point you make about wanting
to change from a singleton to a number of instances in the future
might be valid, but I haven't personally had this problem in using
Scala and I haven't heard of others having problems in Scala.
The main enhancement I would find useful is to be able to extend an
arbitrary abstract class when making an enum. The present proposal of
a special abstract enum wouldn't help my use cases much. Therefore I
don't thing the Singleton variation is that important.
2009/5/12 Tim Peierls <tim at peierls.net>:
> I'm saying I am not in favor of a change to the Java language that would
> make Foo.bar() a shorthand for something like Foo.$synthetic$.bar() when Foo
> is an enum with no members. I think it would encourage people to write
> confusing and hard to maintain code in exchange for the minor and doubtful
> benefit of slightly more compact code. What if your singleton turned out not
> to be a singleton? If you had implemented it as an enum with one member, no
> problem: just add another member. If you had implemented it as an enum with
> no members, you'd have to go back and change all uses of that enum.
> --tim
>
> On Tue, May 12, 2009 at 1:08 AM, Howard Lovatt <howard.lovatt at iee.org>
> wrote:
>>
>> Hi Tim,
>>
>> 2009/5/12 Tim Peierls <tim at peierls.net>:
>> > It just doesn't seem worth the pain of a language change to me. If I
>> > were
>> > ever really at a loss for a name for the singleton instance, I could go
>> > minimal.
>> > enum SingletonEnum {
>> > _;
>> > void method() { System.out.println("method called"); }
>> > public static void main(String... args) {
>> > SingletonEnum._.method();
>> > }
>> > }
>> > Or "THE", or "IT". But usually there's a natural name:
>> > // Socratic singletons
>> > enum Good { KNOWLEDGE; ... }
>> > enum Evil { IGNORANCE; ... }
>>
>> I was probably in your camp until I started to use Scala and I found
>> the object construct and the concept of a closed set of instances most
>> useful. Since using a Scala a bit I think the construct is worth
>> while. Have you used Scala or some other language with this construct?
>>
>> -- Howard.
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
--
-- Howard.
More information about the coin-dev
mailing list