On 30/03/2010 09:08, Weijun Wang wrote:

> I know such a simple thing can be made very complex and everyone might
> want to add a new method into it. How about we just make it most
> primitive? Simply an immutable and Serializable class, two final
> fields, one constructor, two getters (?), and no static factory
> methods.

Even with the diamond operator, I'd prefer a static creation method to a constructor. Immutable value classes really should not have constructors. I'd also like to support Comparable for Comparables.

>          (S)he who does the real implementation has the privilege to
> choose between head/tail and car/cdr.

Or are you suggesting an abstract base class to support two-field immutables? IMO, a good idea from a strong-typing perspective, but lazy programmers will probably want a concrete pair or they'll keep implementing their own.

Tom

Reply via email to