PROPOSAL: Abstract enums (version 2)

Howard Lovatt howard.lovatt at iee.org
Sat May 9 15:40:02 PDT 2009


Yes a single element enum is a great singleton. Instead of:

I was proposing shorter syntax, e.g.:

enum Singleton {
  INSTANCE;
  void method() { ... }
  ...
}

I was proposing shorter syntax, e.g.:

enum Singleton {
  // No INSTANCE
  void method() { ... }
  ...
}

Usage:

Singleton.method();

Note usage without reference to INSTANCE. To make this really powerful
you need to be able to extend an arbitrary class.

I should have given an example to prevent the confusion - my fault :(

 -- Howard.

2009/5/8 Tim Peierls <tim at peierls.net>:
> On Fri, May 8, 2009 at 1:51 AM, Howard Lovatt <howard.lovatt at iee.org> wrote:
>>
>> Further it would be nice if you could make a singleton by having a enum
>> with *no* members.
>
> I don't understand what you mean here. A one element enum makes a great
> singleton. (Effective Java 2nd ed., Item 3.)
> --tim
> ______________________________________________________________________
> 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