Latest Thinking

John Rose john.r.rose at oracle.com
Thu Jun 24 00:28:38 PDT 2010


On Jun 23, 2010, at 8:27 PM, Howard Lovatt wrote:

> Can't you just qualify the name

The same observation applies to 'java' in 'java.lang.String' as to unqualified 'String'.  The point is that identifiers have context-sensitive meanings in Java.

Expression contexts have different resolution rules from type contexts, which means type names aren't compatible with expression contexts.

The JLS documents this fully in the section on names, and is worth reading carefully when pondering language puzzles like this.

It is true that previously-undefined names could in principle be given new meanings without breaking old programs, but this is a dangerous design tactic given wildcard imports and inheritance, which can bring names into scope suddenly due to non-local API changes.

Java will never be a single-namespace language.  Try Scala or Scheme!

-- John


More information about the mlvm-dev mailing list