David A. Black wrote:
> Hi --
> 
> On Tue, 8 Jun 2004, Hal Fulton wrote:
> 
> 
>>Semantics, James Thurber notwithstanding, is not a town in Ohio.
>>
>>I think when Rich says "semantics" he means something that can't
>>really be checked by a machine -- the "purpose or function," as it
>>were.
> 
> 
> Yeah, I think you're right.  I'd been interpreting the term as a kind
> of collective reference to things like signature, return type, etc.
> (which is why I'd had trouble finding any of them in Ruby methods :-)

Method semantics are about *what* a method does.  For a class to be a 
subtype (i.e. Duck type-able ... is that a word?), it must obey the 
Liskov Substitution Principle (LSP).  In general that means (1) the 
method names need to be the same, (2) they take the same arguments and 
(3) they have compatible (but not necessarily identical) semantics. 
Using respond_to? just checks (1).

I don't have time this morning to say more than this, but I recommend 
the white papers at objectmentor.com as a starting place for reading 
about LSP and other design principles.  Also 
http://archive.eiffel.com/doc/manuals/technology/contract/ is a good 
beginner's article on Contracts (which is one way of actually specifying 
semantics).

-- 
-- Jim Weirich    jim / weirichhouse.org     http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)