PRE-PROPOSAL: Source and Encoding keyword
schulz at e-spirit.de
Sat Mar 7 13:05:22 PST 2009
Reinier Zwitserloot schrieb:
> Meta-data (at least the source and encoding keyword) is part of
> *EVERY* java file already. If you give me a UTF-16 encoded file, that
> fact is part of that file, period. I can't compile it without knowing.
> Same with source compatibility. Making it an explicit part of the file
> (with our proposal) is therefore only good news.
Firstly, I was thinking about SVN already handling these meta-data, and
of course external to the actual file. Secondly, a file may be encoded
in UTF-8, but that does not make the meta-information be a required part
of the file itself. In general, meta-information not necessarily has to
be stored within the resource it is related to (although it might be
more handy to do so).
> Magic Comments is a very bad idea because it is first of all obviously
> a kludge, but it also sets a bad precedent: All java parsers out there
> now need to parse comments instead of skipping them, which causes very
> big differences in tokenizer architecture. The tokenizer is also not
> allowed to quit with an error when it can't parse a magic comment,
> because there's no telling if it might be some future magic comment
> syntax that was also introduced to avoid backward incompatibilities.
> It's technically not backwards compatible, and finally: it's ugly.
> Note that the proposal has already stated that encoding and source
> keywords must precede everything else except comments. You can't
> really demand that these precede all comments, because many tools add
> a comment at the top of every file (for e.g. a licence).
Well, as you said yourself, it is meta-information on the resource in
question. As a consequence to me, these information do not belong to the
Java Language and do not deserve keywords for themselves. There already
is a notation for expressing meta-information in Java: Annotations. Your
argument against Annotations is that they must not influence the outcome
of the compilation. Well, for your cases of encoding and source they
don't. These only flag the compiler on how to properly read the code.
More information about the coin-dev