?????? ??? ?????, 28 ????? 2012 13:14:02 UTC+1, ??? Heikki Kallasjoki:
Presumably that's regarded as a class which is part of the program,
rather than the program itself. If I write two methods called tan(),
one of which performs the mathematical operation whilst another
switches on a machine in a sun parlour, we wouldn't expect linking the
two libraries to have idential results. That's true of almost every
programming language.
I'm not sure what 'class which is part of the program, rather than the
program itself' is intended to mean. All Java packages with first
component java or javax, and classes in them such as java.io.File
here, are reserved for definition by Sun^WOracle. System is actually
java.lang.System (because java.lang is automatically visible in all
Java code, unlike all other packages) and thus similarly standard.
Most java.* packages are part of the (JRE) standard library and thus
usable from any Java code; since Java is dynamically linked, a
complete program can only be defined sensibly as a main routine and
everything its execution can -- or more strictly, does -- access.
In C and some older compiled languages there is a global namespace for
'external' (in C, non-static) routines and variables, so yes two
different 'tan's can be a problem. C++ has namespaces which can be
used to disambiguate, but IME people rarely do. Fortran>=90 has
one-level modules, but it's not clear to me how much they are used; a
lot of Fortran code is 'dusty decks' from long before 1990.
Ada and Java have hierarchical package naming, which people do use.
The two tan's in your example would actually be something like:
org.mathlovers.Trigonometry.tan
com.New_You_483.Farrah.tan
and Java the full 'path' is in the .class file and used for dynamic
linking at runtime to get the correct one.
Some languages allow overloads of routines/methods with different
parameter lists. Java distinguishes these in the .class file; C++
typically uses mangled linker names (though the standard doesn't
specify); Ada usually needs a special or modified linker anyway and
can also resolve on expected return type. (Fortran>=90 allows you to
user-define generic names which call different routines depending on
argument types, but those 'specific' routines do have unique names --
although possibly 'private' ones you can't directly use in a call.)
So java.io.File.separator is always, on every valid JVM, a specific
Suncle-defined variable with a platform-dependent value which is in
fact different on different JVMs, falsifying your overbroad claim.
What *is* standard across all platforms in Java is the core language
-- e.g. int arithmetic is 32-bit 2's-complement with wraparound --
except as you said (almost) floating-point in the absence of strictfp;
and a large fraction of the standard library (up to resource limits,
and there Java is at least safe, unlike some C implementations).
Java also has a fair chunk of library functionality altered by locale
(e.g. character encoding, date-time format) or timezone; so does C
(and C++). This is a grey area that makes 'strictly conforming' even
more useless, since it produces different results even on machines of
the same type or users on the same machine, which are intended to be
and usually(?) are all correct.