PRE-PROPOSAL: Source and Encoding keyword

Howard Lovatt howard.lovatt at iee.org
Sun Mar 15 04:30:33 PDT 2009


Since I proposed a source keyword a while back,
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519124, I am
obviously biased in favour of this proposal. I think the place for
source is in the file, since the compiler deals with files. The
advantage of a source statement is that it positions Java for the
future:

1. There are many proposals around that would benefit from more syntax
changes than is currently possible. The obvious current one is module,
instead of burdening every tool with a new parsing technology - just
make module a keyword. Remember exotic names are already in coin,
therefore you can still call old code that uses module as an
identifier.

2. Many proposals for the language jump through hoops it trying to
avoid new keywords (I'm talking about you BGGA). These proposals end
up looking nothing like Java as a consequence. Java uses unabbreviated
keywords, e.g. extends instead of :, this is part of the character of
Java. You need a source statement to enable new keywords and hence
enable future extensions that don't appear alien.

3. When there is a reliable library dating scheme (maybe as part of
the modules), then the compiler could enforce this also (this would be
true for both -source and source in the file). Reliable library
management is something separate, but one in place source will be able
to use it.

The argument that the JLS doesn't spell out what the current -source
flag does, but would have to if source were added to Java is a bit
weak. The -source flag exists, it is documented, that documentation
could be moved into JLS. If the documentation is not up to JLS
standard then at some point, not necessarily now, it will need
improving. Remember that this is nothing new, other than putting it
into the file. -source already exists, it already has some
documentation (people including compiler writers seem largely happy
with its documentation).

My motivation for the source keyword came form network protocols (and
similar) that have a version number. This has proved a very successful
way of maintaining backward compatibility and still adding new
features, the same would be true for a programming language. Since
there is not much time for coin there is little that this change would
add to 6, other than making module a true keyword, but the big picture
is the future changes are much more manageable (it is a future
proofing strategy - part of a grand plan).



More information about the coin-dev mailing list