GIGO: words unreadable aloud
Mishrogo Weedapeval
 

 

  Saturday 19 June 2004
Chapter 5, Exercise 9

I don't think the phrasing means what Bruce intended for it to mean. The exercise asks Create a new directory and edit your CLASSPATH to include that new directory. Copy the P.class file (produced by compiling com.bruceeckel.tools.P.java) to your new directory and then change the names of the file, the P class inside, and the method names. (You might also want to add additional output to watch how it works.) Create another program in a different directory that uses your new class.

I don't see any tools suggested in this chapter that would let me change the P class and the method names inside the P.class file. I suspect that such bytecode-editing tools exist, but I also suspect that he probably meant to change the name of the SOURCE file, and the method names in the SOURCE file.

THECLAPP is still out of synch; he calls this exercise 10. And he ran into the same wording problem that I just described.

The Scala Implementation Status page warns us that Members of the empty package cannot yet be accessed from other source files. Hence, all library classes and objects have to be in some package.

So, I put c5x9_W.scala:

package x;
object W {
    def r ( s: String ) = Console.print( s );
    def rn ( s: String ) = Console.println( s );
}
into an "x9" subdirectory. Cd'd in there and compiled it in there. the W.class (and W$.class) files get generated into a further subdirectory called "./x9/x".

Then, I made c5x9.scala in x9's parent directory:

package x;
object c5x9 {
    def main ( args: Array[String] ) = {
        W.r( "one string ... " );
        W.r( "another string ... " );
        W.rn( "a final string followed by a Newline." );
    }
}

And I compiled that file like this: CLASSPATH=x9 scalac c5x9.scala and ran it like this: CLASSPATH=.:x9 scala x.c5x9 .
11:53:57 PM   comment/     



Click here to visit the Radio UserLand website. Click to see the XML version of this web page. © Copyright 2007 Doug Landauer .
Last update: 07/2/6; 12:40:46 .
Click here to send an email to the editor of this weblog.

June 2004
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
May   Jul

Previous/Next