Re: terminology
On 04/19/2012 09:40 PM, Stefan Ram wrote:
markspace<-@.> writes:
java.lang.Thread . dumpStack() java.lang.System.out . print( 2 )
I do call the source code part in front of the last dot a
/context/.
Fully-qualified type name.
I'd have said the same off the top of my head. I'd also call it a
"class" if FQN was a bit long, or I was being less strict in my speaking.
A ??type name?? is a special kind of context, it is a static context.
My usage does not come from the JLS, but from javac who says things like:
Main.java:7: error: non-static method length() cannot be referenced from a static context
String.length();
^
1 error
When you teach java [sic], explaining vocabulary of javac can't be
that wrong, even if it's not as authoritative as the JLS.
Obviously, the ??static context?? above is ??String??.
No. 'String' is the (simple) type name. The static context is the semantic
space to the right of the dot.
I cannot call this ??type name??, since the part in front of
the last dot is not always a type name, as in
java.lang.System.out . println()
. ??java.lang.System.out?? is the context of ??println()??
(in my terms), but it is not a type name.
"Context" is a general term, and the javac output is using it exactly as the
JLS does. Static contexts occur other than by a type name, e.g.,:
public class Foo
{
static
{ // static context
}
}
There is nothing wrong with using these terms as the JLS does.
When you teach Java, the vocabulary of the JLS can't be wrong. (Well, there
are questionable items in there, but that's another matter.) Trying to go
against it, especially diametrically, can be.
More subtly, you misidentified the static context in the 'String' call to
'length()'. "Context" is used in its ordinary, English sense in the JLS, and
in the concomitant "javac" output. It means, in that example, that at the
point of evaluation of the method name, that is, to the right of the dot, the
semantic environment is that of the type specified by the type name to the
left of the dot. By the rules of Java, since it's a type name and not an
instance name, the context is static. Likewise in a static initializer, to
between the braces is a static context. "Context" means the environment or
ontological background - are we looking at the world from the class-wide
(static) view or the instance view?
I aver that you're going about this backwards, thus impeding understanding of
Java. Instead of trying to map your terms to what exists in Java, start with
the Java terminology and grok what they really mean. Then, if you still really
feel the need, come up with synonyms, rather than shoehorning alien concepts
into the Java space.
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg