James Watson
Posts: 2024
Nickname: watson
Registered: Sep, 2005
|
|
Re: A Brief History of Scala
|
Posted: Jun 15, 2006 7:02 AM
|
|
> Martin, > > thanks for reading and answering. > > I agree that at this stage you need to pick your > priorities. And some are well chosen, even "simple" things > like providing an Eclipse plugin. We developers certainly > want that. And also that you don't want to "offend" Java > programmers by being too radical, but if something in Java > is bad, it must go, otherwise you will suffer for a long > time. Just see how C++ suffers from its C inheritance. > > Regarding the language support for algebraic structures, > this came partially from my recent attempt to define an > interface for a group. Now, some group requirements are > very hard to code explicitely, e.g., associativity. Here > is my attempt: > > interface AdditiveGroup<T> {
> T negative(); // the inverse
> T plus(T x); // how I would like a "+" in Java
> T minus(T x); // as T plus(T x.negative());
> // can't do: static T zero(); // the neutral element
> }
>
> What's frustrating in Java is that I cannot define a > class-level method to return the neutral element as Java's > interfaces don't allow static methods. An instance-level > method is not really viable since I would need to create > an object before I can get the one and only neutral > element of the group. > > Actually, what I'd really like to define is this (in > pseudo Java):> interface Group<T, op> {
> T op(T x);
> T negative();
> static T id();
> }
>
> // example: group of all integers Z =
> {...,-2,-1,0,1,2,...}
> public class Z implements Group<Z,+> { ... }
>
, i.e., parametrise on the type, T, and the > operation, op. > > The above Java interface is an example where the language > design restricts/hampers/denies developers to express > important concepts.
Can you explain what this interface means a little bit? Are classes that implement it a member of the group or members of the set of group?
I think there may be a way to get what you want in Java but I'm not sure.
|
|