[48] in java-interest
Proposed Java Language Extentions
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Thu May 4 18:04:34 1995
Date: Thu, 4 May 1995 13:55:58 -0700
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: java-interest@java.Eng.Sun.COM
Hi,
These are the notes on the Java Language meeting of Thursday the 4th of May.
(1) Alternative notations for methods returning array. Accepted.
Currently a method that returns an array is declared as follows:
int foo()[] {
...
}
Although this is consistent with Ansi-C it is considered
fairly obscure. We have agreed to also allow the notation
where the []'s appear after the return type. For example:
int[] foo() {
...
}
Note that the old syntax will still be allowed. As a result we will
also allow the []'s to follow types in other declarations. For
example, this declares two arrays of integers:
int[] a, b;
For completeness and backward compatibility it will be allowed
to mix both notations (it should be discouraged though). The
following declares 'a' to be an array of integers and b to be
an array of arrays of integers.
int[] a, b[];
(2) Introduce Enumerations. Postponed. We could not form a consensus
on the exact nature of enumerations. It was agreed though that
in no case enum's should be the equivalent of creating a new type.
We only considered adding type-less enums which help you declare
a series of constants with a type and a unique value.
(3) Allow /** ... */ comments everywhere. Accepted. We agreed that
doc-comments will be allowed everywhere, but when used out of
context they will generate a warning.
(4) Introduce //* comments. Rejected.
(5) Clarify the meaning of (a)-b. Document. Accepted. This notation
could be interpreted as a cast or as a subtraction. The current
compiler considers it to be a cast if 'a' is a simple type expression
otherwise it considers it to be a substraction. We agreed that this
is the right thing to do and that it should be documented in the
Java language spec.
(6) Combine try-catch and try-finally statements. Accepted. Currently
a try statement can have either 1 or more catch clauses OR
1 finally clause but not both. This is considered confusing.
We agreed that a try statement should be allowed to have
0 or more catch clauses and an optional finally clause.
For example:
try {
...
} catch (Exception e) {
// executed when exception occurs
...
} finally {
// always executed, even when an exception occurs
...
}
(7) Instanceof and type Coercion. Postponed. It turns out that
you often write code like:
if (x instanceof Foo) {
Foo foox = (Foo)x;
...
}
It would be nice if there was some construct where you could
test if x is an instance of Foo and then use it as a Foo
without having to cast it. We could not agree on a good syntax
that would have little impact on the language and the runtime.
(8) Multiple return values. Postponed. Java allows only one return
value which is often annoying and may lead to inefficient code.
Two alternatives were proposed. Mesa syntax (would affect both
the method declaration and method calls, I'm not sure what the
Mesa syntax for a method declaration with multiple return values
is though).
[a, b] <= foo(c)
And a more IDL like syntax (would only affect method declarations)
int foo(in int a, inout int b, out int c) {
...
}
The Mesa syntax was considered clearer, but the IDL syntax is
closer to C/C++ and has the advantage that it can be used in
expressions. The problem with the IDL syntax is the introduction
of 3 new keywords that are already widely used as identifiers.
(9) Trailing comma in array initializers. Accepted. You will be
allowed to write:
int x[] = {1, 2, 3, };
(10) Nested /* */ comments. Rejected. It is currently impossible to
comment out a method that either contains /* */ comments or has
a documentation comment. Allowing nested comments would solve this
problem. It was [unfortunately] rejected though on the basis that
it is incompatible with Ansi-C.
All the issues marked Accepted will be implemented in some future
release of Java/HotJava. Items marked Postponed will be discussed again
in a future Java language meeting.
Please feel free to send in your comments.
Have fun,
Arthur van Hoff (avh@eng.sun.com)
http://java.sun.com/people/avh/
Sun Microsystems Inc, M/S UPAL02-301,
100 Hamilton Avenue, Palo Alto CA 94301, USA
Tel: +1 415 473 7242, Fax: +1 415 473 7104
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com