-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Jun 22, 2003 at 01:51:04PM -0700, Ben Barrett wrote:
> 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)
> }

It is.  Java is a pass by value language, as far as the coder is
concerned.  You cannot simply swap pointers like that.

Essentially, the exercise was chosen specifically to find something that
Java cannot do in the way you can do it in another language in order to
claim that Java is therefore inferior and restrictive.

The way you would do this in Java is to define an interface Swappable and
make your classes implement it.  You can't do the swap as it is done above
with Python either, but Larry demonstrated a very easy solution invoiving
returning a tuple.



> 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..

That doesn't easily solve the problem.

- -- 
Joseph Carter <[EMAIL PROTECTED]>             Only l33t on Thursdays
 
<dark> "Let's form the Linux Standard Linux Standardization Association
        Board. The purpose of this board will be to standardize Linux
        Standardization Organizations."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
Comment: 1024D/20F62261F1857A3E79FC44F98FF7D7A3DCF9DAB3

iEYEARECAAYFAj72NWsACgkQj/fXo9z52rMKLwCfYa8alIwOKIPlAVa1yFucLJvS
nncAn0n6yIrqW2QgQgwO1B3LctB7KSlR
=v5Nl
-----END PGP SIGNATURE-----
_______________________________________________
EuG-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug

Reply via email to