Custom Search
|
Re: more liberal Some.equals Re: Maps in scala
Date: December 28, 2006
In-reply-to:
<ac0ce270612280906j78d40a94s32c4d936109c3956@xxxxxxxxxxxxxx> On Dec 28, 2006, at 12:06 PM, Burak Emir wrote: On 12/28/06, Jay Sachs <jay@xxxxxxxxx> wrote: On Dec 28, 2006, at 10:49 AM, Burak Emir wrote: > do you think it would make sense to define Some.equals method such > that Some(x) == x? But then wouldn't Some(None) == None ? Good point. One could make a special case for None.Options of options are quite rare, and a big obstacle to optimization of option types, but since we have them, it would surely be very confusing to have Some(None) == None. Also Some(Some (x)) should not be == Some(x). So here's what is meant. I think it's difficult if not impossible to get the semantics right. You've eliminated Some(Some(x)) == Some(x), but what if the nested "Some" is inside a list: Some( List(Some(3)) : List[Any] ) == List(3) : List[Any] ) Per your definition above, this evaluates to List(Some(3)) == List(3) which recursively will invoke Some.== and return true. |