From: Its Me Date: 2004-06-09T08:28:37+09:00 Subject: Re: Interfaces and semantics (or, how to hashpipe a duck) "Hal Fulton" wrote in message > For example, imagine that we are concerned with a conceptual "append" > operation. We want to know whether an object is capable of being > appended onto. > > Well, a string is "appendable." So is an array. So is a file. > > str << x > arr << x > file << x > > Aha! Why not just check for << existing? > > Oops. There's a Fixnum#<< which does a left shift! The harder way is to specify the intended/guaranteed effect of the operation (without committing to the implementation e.g. post-condition style contracts). A much easier improvement is to use meaningful parameter names and treat them as part of the method selector. String#<<:item Array#<<:item File#<<:item vs. Fixnum#<<:amount Smalltalk does this. Imho, Ruby should do this when proper keyword arguments are supported.