funny characters in identifiers?
Charles Oliver Nutter
headius at headius.com
Fri Dec 31 19:46:24 PST 2010
On Fri, Dec 31, 2010 at 3:25 PM, Per Bothner <per at bothner.com> wrote:
> A problem with this mangling is that it isn't "safe" for class names,
> or at least not for class files. Using '\' in a filename is obviously
> problematical, especially on Windows. On Posix-based file system the
> funny characters are in principle allowed, but will of course be awkward
> to access from shells and other tools.
I'm only using it in method names, so that didn't bother me.
> Windows disallows the following in file names:
> < (less than)
>> (greater than)
> : (colon)
> " (double quote)
> / (forward slash)
> \ (backslash)
> | (vertical bar or pipe)
> ? (question mark)
> * (asterisk)
> (And of course we have problems with-insensitive file systems.)
> Now of course we can use an annotation to specify the source class name
> in case the source class name is invalid - but then we still need to
> mangle the class name somehow.
> I think a better prefix character would be '%'. It's not reserved
> for Posix or Windows or JVM, while not being a valid Java character.
> Even better might be '~' or '!' since those are also unreserved for URIs.
> I will assume '~' in the following.
% is used for environment variables on Windows
$JAVA_HOME = %JAVA_HOME%
It might be ok embedded in a filename, though...I'm not sure how twitchy it is.
> If we want names that a "safe for filenames" or even "safe for URIs"
> then the problem is that there are too many unsafe characters to
> encode as '~' followed a safe non-alphanumeric. Which means that
> we need to use '`' followed by a *letter*.
It seems like the only safe mangling for anything seen by the
filesystem is going to be alphanumeric plus a couple characters. The
cross-section of characters allowable in a class name and those
allowable (and not troublesome) on all filesystems is very small...
Why do you need this for class *files*?
More information about the mlvm-dev