> If anything, Scala's more likely to go the other direction.  Allow you to
> specify that a particular exception may *never* be thrown from a given
> method.

With separate compilation, I can't imagine that working without also
being able to specify that a particular exception can be thrown from a
given method.

Java already lets you implicitly specify that a method may never throw
an IOException, barring trickery, by simply omitting 'throws
IOException'.

>> HashMap[Shape, Pair[String, String]] shapeInfo = makeInfo()
[snip]
> Out of curiosity, let's assume it was meant to be mutable, so not final.
> - How would you write the same line using type inference?

I wouldn't.  It's reasonably safe to say that if you may assign more
than one value to a variable, the type may not be inferrable.  For
instance, with type inference signified by the word 'var' as it is in
C#, but with Java's anonymous classes:

var foo = new Runnable() {
  public void run() {
  }
};

foo = new Runnable() {
  public void run() {
  }
};

The second anonymous instance is of a different type to the first
(it's not of type Runnable), so any reasonable type inference
mechanism that doesn't do look-ahead will likely cause the above to
give a compile error.

In case anyone doesn't know what I'm talking about there, anonymous
classes do actually create a one-shot type, so the following works:

System.out.println(new Object() { int fac(int x) { return x < 2 ? x :
x * fac(x - 1); } }.fac(5));

> They [primitive types] enjoy stack allocation when passed as method 
> arguments, and Arrays of
> primitives get VIP types, allowing them to be used without boxing/unboxing.

Same in C#, yet in C# there's less fuss about them, and they're less
of a special case.  The fact that they're odd in Java is by no means a
feature.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to