Re: Java global implicit typing

Mike Dean wrote:

> Sergey,
> 
> Below is my example of why I see Java (and C++) as employing
> global implicit typing.  I can use the same literal
> (constant) value with a variety of numeric types, and don't
> have to change it if the type changes among the numeric
> types.
> 
> 	Mike
> 
> lass globalimplicit
> {
>     public static void main(String args[])
>     {
>         short s;
>         int i;
>         float f;
>         double d;
> 
>         s = 5;
>         i = 5;
>         f = 5;
>         d = 5;
>     }
> }

Right; however,

String s;
char c;

c = 5;
s = 5;

won't work.

A general observation: Java syntax corresponds to RDF/XML, whereas Java 
bytecode can be viewed as a counterpart of RDF abstract model. In the 
bytecode, all of the above constants are "locally typed" 
(http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#20080). 
That is, the Java compiler simply provides a convenience mechanism to 
free you from explicit typing of (some!) literal constants. RDF parsers 
(e.g., NTriple parser) could do a similar job...

Sergey

Received on Sunday, 11 August 2002 08:46:25 UTC