Re: myWishList

Daniel Bonniot <[email protected]> Thu, 16 Jun 2005 16:07:21 +0200
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
> nice documentation (classification: eccentric,
> priority: medium, difficulty: low) { 
> why would anybody write a comment other than for
> documentation purposes?

For instance, commenting out a piece of program (class, method). If there was 
only one type of comment, nicedoc would not be able to make the difference 
with real documentation.

> static import (classification: obvious, priority:
> high, difficulty: low) { 
> import static my.Constants; 
> lets you use all the static methods and fields without
> question. 
> }

I agree we should probably have it for compatibility's sake. But is this the 
Java 5 syntax?
Would you care to open a RFE?


> abstract interfaces (classification: disastrous,
> priority: medium, difficulty: high) { 
> I think, along with multiple dispatches, abstract
> interfaces are what make Nice worth learning. having a
> functional background, you guys probably feel more at
> ease with declarations like: 
> Object last(Vector v) = v.elementAt(v.size() - 1); 
>  
> but I don't. 

If all you want to do is to create a new method operating on vectors, this is 
the simplest way to do it. I know Java has taught you to do things in 
non-obvious ways, so this is a case were getting used to the simpler solution 
is worth it ;-)

If the goal is to implement the 'last' method defined in a new (abstract) 
interface, read on. (If I understand well, you want the former, but your 
feature would in any case be useful for the latter case)

> I worked in Java all my life. in my
> humble opinion, if you want to add a method to an
> existing class, do it via an abstract interface.
>  try this instead:
> interface MonsterWithATail { 
> // @returns whether the collection is empty 
> boolean isEmpty(); 
>  
> // @returns the last element of the collection 
> Object last() requires !isEmpty(); 
> } 
>  
> java.util.Vector implements MonsterWithATail { 
> /* isEmpty() is already implemented... phew! */ 
>  
> last() = elementAt(size() - 1); 
> }

I agree this would be natural syntactic sugar for

   class java.util.Vector implements MonsterWithATail;
   last(Vector this) = elementAt(size() - 1);

Another RFE!

 > moreover, I see no semantic difference between an
 > ordinary interface and an abstract one. the very
 > distinction undermines the true value of abstract
 > interfaces.

There are compilation and typing differences. For compilation, you have to 
understand that making a class (like Vector) implement an interface after the 
fact is just not supported in java bytecode. This means that we can only do it 
for special, "abstract" interfaces that do not appear at the bytecode level. I 
don't think it is generally possible to detect automatically which interfaces 
should be abstract without breaking separate compilation.


>  
> and no method should appear outside such clearly
> defined boundaries. public interfaces still are, of
> course, just Java interfaces. but this means you will
> have to abandon the custom constructor syntax, and I
> guess I am more than alright with that. it seems to me
> that sacrificing the flexibility Nice offers right now
> is too precious to give up and this is, I assure you,
> the only thing I am asking for which goes directly
> against the principles of Nice. still, think it over,
> will you?

I don't understand: you think "the flexibility Nice offers right now" (methods 
outside classes?) "is too precious to give up", but you seem to advocate to 
give it up for the sake of clarity.

> IDE (classification: plausible, priority: high,
> difficulty: high) { 

We need contributions in this area (eclipse plugin or other).

> keywords (classification: eccentric, priority: low,
> difficulty: low) { 
> this shouldn't be on even a wish list. there should
> have been something like a fantasy list. the point is,
> all the keywords in Java (and Nice) are whole words,
> apart from: int, char, enum, var, const... could you
> add the whole words to the keyword list, meaning the
> exact same thing? could you? please? on the other
> hand, instanceof, public-read, private-write are
> two-word words. I didn't know about the public-read
> keyword when I was writing the get/set part, if it
> exists, and means what I think it does, I still prefer
> 'sheltered' over it. about instanceof, can we come up
> with a single word alternative? it's just my taste,
> that's all. the language is still young... why should
> it carry the old baggage? 
> }

I'm afraid that allowing systematically two versions of each short keyword 
would be confusing, and a short version is quite handy when typing. Hopefully, 
  this can become irrelevant as higher level representations of code become 
available (see IDE ;-)

Cheers,

Daniel


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click