--nextPart2283964.Y4qBUPjigC
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On Friday 20 October 2006 07:13, dblack / wobblini.net wrote:
> I do think that there's room to adjust and fine-tune how Enumerable
> works, but I wouldn't want to go in the direction of subordinating it
> to Array.

Another way of saying what Dave's saying is that Modules like Enumerable=20
are "mix-ins".  They allow you to mix-in behavior based on the assumed=20
presence of some core existing function.  Mix-ins are a very old concept=20
originating (I believe) with Smalltalk.  The power lies in the fact that if=
=20
you want to implement the functions in Enumerable, all you have to implemen=
t=20
is a single function: each().

Mixins are similar to abstract classes in Java, only Rubyists tend to use t=
hem=20
properly whereas (in my experience) most Java programmers don't understand=
=20
the concept properly and so don't take full advantage of it.  Plus, you can=
=20
mix in multiple modules in Ruby, whereas you can only inherit from a single=
=20
abstract class in Java.  However, you *can* implement Enumerable in Java wi=
th=20
abstract classes:

	pulic abstract class Enumerable {
		public boolean include( Object value ) {
			for (Iterator itter =3D getIterator(); itter.hasNext(); ) {
				Object curr =3D itter.next();
				if (curr.equals(value)) return true;
			}
			return false
		}
		// Etc.  Find, grep, collect, max... can all be defined using only
		// the information that we get in an iterator of the objects.
		public abstract Iterator getIterator();=20
	}

Enumerable is not synonymous with Array, and Strings only look like Arrays =
of=20
characters because Americans first implemented them that way and everybody=
=20
since has followed the convention.  ASCII still has a stranglehold on the=20
computer industry. When you start venturing into I18N and start dealing wit=
h=20
alternative encodings, then the analogy breaks down.  Which end of a String=
=20
of Arabic (written right-to-left) characters do you start iterating from? =
=20
What's the result of adding two of those strings together?

=2D-=20
### SER  =20
### Deutsch|Esperanto|Francaise|Linux|XML|Java|Ruby|Aikido|Iaido
### http://www.ser1.net  jabber.com:ser  ICQ:83578737=20
### GPG: http://www.ser1.net/Security/ser_public.gpg

--nextPart2283964.Y4qBUPjigC
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQBFOMMBP0KxygnleI8RAlAdAKCQQuayABVOofhzAFGJmhFPP8VgwgCgiJzI
yEzGDc97YZ2v6MIlQvZfT7w=
=EUtA
-----END PGP SIGNATURE-----

--nextPart2283964.Y4qBUPjigC--