"jared l. jennings" <jjenning / stetson.edu> wrote in message
news:42377.13773$4v6.1187442 / e420r-atl3.usenetserver.com...

> umm, can you just give everything a clip method? i don't see why not. i
think the reason has to do with this intersection thing. anyway read on.

I this case I could, but it was the best example I could pull out of the
hat. Now imagine that the example was for a second revision of the code
where not all objects originally supported the intersection interface. Then
for practical reasons you'd make sure the interface is supported. This is
btw how software often in praxis evolve, unlike the ideal world of object
models.

More generally, object collections frequently contain different kinds of
objects. You can't rely on them all supporting the same method (or
interface). One example is a symboltable (except a Ruby symbol table of
course :), where each symbol type has some special characteristics. This is
also where it would be nice to iterate over all constants, or all variable
instances, etc.

> print "f is a Mix!\n" if f.is_a? Mix

Which just goes to prove that when you think you are missing the blantantly
obvious, you usually are.

Let's just use an empty module, and you have my contract.

> supporting = collection.find_all {|thing| thing.is_a? ContractModule }
> supporting.each { ... }

Yep - I might prefer some kind of filter solution so as to avoid a separate
collection though, but that is easily done if the original collection
supports it. That is, if it is_a? ContractIterator.

Why do I find it increasingly difficult to fault this language?

One thing would be the high risc of runtime errors, but that was just cut in
half.

Mikkel