Damian Conway <[EMAIL PROTECTED]> writes:

> Paul Johnson wrote:
> 
> > I've always found the word "like" to be very wishy-washy in a computer
> > langauge.  In what way is newbaz like baz?  And just how alike are they?
> > There must be a better way to describe this.
> 
> Perhaps:
> 
>       method set_baz($newbaz is compatible($.baz)) { $.baz = $newbaz }  
>       method set_baz($newbaz is typeof($.baz)) { $.baz = $newbaz }  

FYI Ruby has:

a.type <= b.type  or  a.type == b.type

where the various operators (<, >, ==, != ...) are overloaded
according to the subtyping relation.

as for me, 
- i find the "==" very readable, 
- but i'm not sure "<=" is very readable
  (who knows that a supertype is "greater", and a subtype is "smaller")
  i prefer a.is_a?(b.type)

.... 

<=> is also defined but it seems broken since it returns 1 when there
is not subtyping relationship between 2 types.

Reply via email to