theclapp

Search theclapp.blog-city.com

 

January 2003



Chapter 6, ex 1

Thursday, 30-Jan-2003 12:59 A GMT-04
Chapter 6, exercise 1, Java version:--- // ch06_ex01.java import com.bruceeckel.tools.P; class A { A() { P.rintln( "A constructor called" ); } } class B { B() { P.rintln( "B constructor called" ); } } class C exte

Shortest Path -- Java version

Wednesday, 29-Jan-2003 12:59 A GMT-04
Last week I posted the Lisp for a "shortest path" program. I developed the initial code over several hours that Monday night, posted it, tweaked it a bit in the last day or two, and updated it. Last week I also re-did the same program in Java. I

Grammar rant

Tuesday, 28-Jan-2003 12:59 A GMT-04
Why can't people get it? Use "it's" to mean "it is", and "its" to mean "possessive it". Compare "it's cold" vs. "its hard drive crashed." For plurals, add an "s", or drop a "y" and add "ies", etc. DON'T add an "'s". *sigh* Bad plurals: Aggreg
Category: Rants

Shortest Path -- Lisp version

Tuesday, 21-Jan-2003 12:59 A GMT-04
In comp.lang.lisp, "James" recently asked how to implement a shortest path search in Lisp. It sounded like an interesting problem, so I wrote it.;;;; A fairly inefficient shortest-path algorithm -- find all possible paths, ;;;; then their costs, th

Chapter 5, ex 10-11

Monday, 20-Jan-2003 12:59 A GMT-04
Skipping 5.10. Don't really understand the exercise -- copy the class file and then modify its name and the classes within it? Huh? It seems pretty elementary to me, anyway. Sorry, Bruce. 5.11 18-Jan-2003, 22:47 -- Starting 5.11, Java versi

Chapter 5, ex 8-9

Sunday, 19-Jan-2003 12:59 A GMT-04
5.8 This exercise says to change Bruce's code, which he copyrighted, so I can't post it. I can post the results, though:--- % javac CookieTest.java CookieTest.java:8: bite() has protected access in dessert.Cookie c.bite();

Chapter 5, ex 7

Friday, 17-Jan-2003 12:59 A GMT-04
20:05 -- Starting 5.7, Java version 20:20 -- finished a while ago. Rereading public/private/protected/etc.--- // ch05_ex07.java import com.bruceeckel.tools.P; class LocalClass { protected int data; } class ch05_ex07 { public static

Chapter 5, ex 5-6

Friday, 17-Jan-2003 12:59 A GMT-04
Chapter 5, ex 5: I modified Bruce's example code (TestAssert.java), which he copyrighted, so I can't show it here. The exercise consists of compiling and running the code, then uncommenting one line and commenting out another, then compiling and run

Defining package names and Importing and exporting symbols

Friday, 17-Jan-2003 12:59 A GMT-04
I wondered a bit whether I should use keywords or strings to define package names and/or import and export symbols. I Googled around a bit, and checked the CMUCL source. Most people seem to use strings for both. This makes sense, I suppose -- you

Chapter 5, ex 4

Friday, 17-Jan-2003 12:59 A GMT-04
I consider Chapter 5, ex 4 basically make-work. Vim/Emacs automation is your friend. I suppose the P class may come in handy later. Skipping Lisp version, in case you hadn't caught on. :)

Chapter 5, ex 3

Thursday, 16-Jan-2003 12:59 A GMT-04
5.3, Java version--- // ch05_ex03.java import com.bruceeckel.simple.*; import java.util.*; class ch05_ex03 { public static void main(String[] args) { Vector v = new Vector(); } } ---Results in ch05_ex03.java:8: reference to Vect

Chapter 5, ex 2

Thursday, 16-Jan-2003 12:59 A GMT-04
20:27 -- Starting 5.2, Java version 20:35 -- done--- // ch05_ex02.java // class ch05_ex02 { // public static void main(String[] args) { // mypackage.MyClass m = new mypackage.MyClass(); // } // } // OR import mypackage.*; clas

Poll blog: I prefer ...

Thursday, 16-Jan-2003 12:59 A GMT-04
I prefer ... Java, Lisp, C++, Smalltalk, Perl, other Please leave your comments here. 16-Jan-2003, 20:02: WooHoo! My first confirmed reader! Someone voted in my poll! *laugh*

Annotated ANSI Common Lisp, by the CS dept. at Northwestern

Thursday, 16-Jan-2003 12:59 A GMT-04
Annotations on Graham's ANSI Common Lisp

Chapter 5, ex 1

Thursday, 16-Jan-2003 12:59 A GMT-04
11:25 -- Starting 5.1, Java version 11:27 -- Done--- // ch05_ex01.java class ch05_ex01 { public static void main(String[] args) { java.util.ArrayList[] ar; } } ---Not much to it, really. :) 5.1, Lisp version. Not especially sim

Chapter 5 discussion

Thursday, 16-Jan-2003 12:59 A GMT-04
Bruce calls Chapter 5 "Hiding the implementation". This discusses, among other things, public, private, and protected access specifiers. Given the way CLOS works, I suspect very little of Chapter 5 will apply to Common Lisp.

Chapter 4, ex 20-22 -- skipped

Thursday, 16-Jan-2003 12:59 A GMT-04
I skipped 20-22.

Chapter 4, ex 19

Wednesday, 15-Jan-2003 12:59 A GMT-04
23:03 -- Starting 4.19, Java version 23:32 -- done. Spent some time looking for a function to format floats (actually doubles) for printing, but didn't find one quickly enough, so here's the code.--- // ch04_ex19.java class ch04_ex19 { stati

Chapter 4, ex 18

Wednesday, 15-Jan-2003 12:59 A GMT-04
20:54 -- Starting 4.18, Java version 20:57 -- Done--- // ch04_ex18.java class ch04_ex18 { String string1; { string1 = "init in instance init area"; } void demo_init() { System.out.println( "string1: " + string1 ); }

Chapter 4, ex 17

Wednesday, 15-Jan-2003 12:59 A GMT-04
20:32 -- Starting 4.17, Java version 20:40 -- done--- // ch04_ex17.java class ch04_ex17 { static String string1 = "init at def"; static String string2; static { string2 = "init in static block"; } static void demo_inits() {

Chapter 4, ex 14-16

Wednesday, 15-Jan-2003 12:59 A GMT-04
4.14 -- Verify that Java performs default initialization. Skipping. 4.15 -- Demonstrate that Java initializes uninitialized references to null. Also skipping. 20:09-20:14 -- 4.16 -- Java version--- // ch04_ex16.java class ch04_ex16 { Strin

UPN Lied!

Wednesday, 15-Jan-2003 12:59 A GMT-04
Circa 7:20pm: The local UPN affiliate flashes a transparent banner during Friends: Buffy the Vampire Slayer at 8! Yay! Then at 8 they put up this stupid Funky Flubs. I was annoyed. Oh well. Back to Java.
Category: Rambling

Chapter 4, ex 13

Wednesday, 15-Jan-2003 12:59 A GMT-04
13:44 -- starting 4.13, Java version 13:59 -- done--- // ch04_ex13.java class ch04_ex13_Tank { static int num_tanks = 0; int i; boolean filled; ch04_ex13_Tank() { i = num_tanks++; filled = false; } public void fin

Chapter 4, ex 12, Java only

Wednesday, 15-Jan-2003 12:59 A GMT-04
09:40 -- starting 4.12, Java version 09:43 -- Done--- // ch04_ex12.java class ch04_ex12 { int i; public void finalize() { System.out.println( "Finalizing object." ); } public static void main(String[] args) { ch04_ex12

Chapter 4, ex 11, Java only

Wednesday, 15-Jan-2003 12:59 A GMT-04
08:39 -- Starting 4.11, Java version 08:46 -- done--- // ch04_ex11.java // I ran this code, and saw no message. Obviously gc didn't run. class ch04_ex11 { int i; public void finalize() { System.out.println( "Finalizing object." );