On Wed, 28 Jun 2000, Dr Wes Munsil wrote:

> Perhaps what you mean is that the class passed to ReflectObject.newInstance() must
> identify the _type_ of the _expression_ that is the third argument (sometimes called 
>the
> compile-time type), not the _class_ of the _object_ referred to by that expression
> (sometimes called the run-time type).

Well, if you like those words better :)

> If this is so, wording such as the above would make that clearer, I think. And it 
>would
> mean that the correct answer for my particular example would be Object, since that 
>was
> the type of the expression.
> 
> Seems a little strange to couple a compile-time notion with run-time semantics, but 
>if
> it needs to be that way, then so be it.

There is no "compile time" in Tcl, it is all dynamic, so there is 
no other way to do it. Just think of it like this.

VarObject obj = new String();

(now lets pretend we can change the type of the obj ref dynamically)

obj.setClass(Object.class);

obj.toString();

obj.setClass(String.class);

obj.charAt(0);



This is exactly what is going on behind the scenes in Tcl/Java.

set obj [java::new String]

set obj [java::cast Object $obj]

$obj toString

set obj [java::cast String $obj]

$obj charAt

See what I mean?


Mo DeJong
Red Hat Inc

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to