I think "inconvenience" is the correct term!  I'm still confused about
your hangup on a subroutine.  Is this wrong: (?)

void swap(Object a, Object b) {
        Object temp = a; a = b; b = temp;
        // (only change SomeClass to Object)
}

Also, you may want to remember the System.lang.reflect tools when you
need a handle  ( =   For example, with an object o:

Class c = o.getClass();
//then later
c = c.getComponentType();
//these examples are expounded upon on p.147-148 of
//O'Reilly's Java In a Nutshell, 3d ed.

Im sure you can find some interesting bits by searching the newsgroups
and mailing list archives for java reflection code and discussion.
There are many hacks in the API, and well-designed code should of course
use the calls which provide the best-time implementation, in terms of
complexity.  Unfortunately, some things change with JDK from version to
version, and Java's reliance on Sun is another issue for debate...

I can report that the country fair site is coming along nicely --
there's a *lot* of activity out there, and the fair itself is just
around the corner.  I have some new pictures of treeclimbing to help
setup the wireless network out there; and if anyone in the group has
suggestions for techie projects (which might help link the rest of
euglug's members with the event?) relating to the oregon country fair.

have a great sunday, shanti,

   Ben Barrett


On Fri, 20 Jun 2003 23:10:11 -0700 (PDT)
Neil Parker <[EMAIL PROTECTED]> wrote:

| On Fri, 20 Jun 2003, Ben Barrett wrote:
| >So, what is the problem we are really looking at?
| >There are so many negative sentiments regarding Java,
| >but I think it has its benefits, and is worth knowing
| >what it is good for... right tool / right job, after all.
| 
| The original problem, as stated to me a couple of years ago, is this:
| 
| Given two Java objects, a and b, write a function that swaps them,
| i.e. after executing
| 
|      swap(a, b);
| 
| a should contain the former contents of b, and b should contain the
| former contents of a.
| 
| The point, I think, is to illustrate how pointers are more restricted
| in Java than in C, and to provide fodder for those who like to
| complain about the inconvenience of languages that try too hard to
| protect you from yourself.[*]
| 
| The task is, of course easy to do in Java:
| 
|      {SomeClass temp = a; a = b; b = temp;}
| 
| What's hard is writing a Java SUBROUTINE to do it.  It has to be a
| subroutine...i.e. something that looks like this:
| 
|      void swap(Object a, Object b) {
|           // (put your code here)
|      }
| 
|                     - Neil Parker
| 
| [*] See
| http://catb.org/esr/jargon/html/B/bondage-and-discipline-language.html
| 
_______________________________________________
EuG-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug

Reply via email to