I dislike exceptions because they're not referentially transparent
(they break f(x) == f(x)) like the gotos they are.  That said, they're
handy sometimes.

As for pattern-matching, there's nothing inherently bad about it, but
usually or perhaps always with scala.Option, there's a better way of
writing code using HOFs.

On Tue, Oct 30, 2012 at 10:58 PM, Josh Berry <[email protected]> wrote:
> On Tue, Oct 30, 2012 at 9:41 PM, Cédric Beust ♔ <[email protected]> wrote:
>>
>> On Tue, Oct 30, 2012 at 5:15 PM, clay <[email protected]> wrote:
>>>
>>> - Option's main advantage is not avoiding NPE's, but factoring common
>>> null-related conditional logic out of all your code and into a standard
>>> library component.
>>
>>
>> Exactly. I expanded on this point here.
>
> I don't know, any expansion where you have a dig at Tony Hoare seems
> likely to be off. :)
>
>
>> On a related note, I find it funny when people advocate Option because "it
>> forces you to deal with null pointers instead of ignoring them" and then
>> rant against checked exceptions because they force you to do exactly the
>> same thing. I was also a bit surprised that the whole discussion on Optional
>> in the podcast never mentioned a single time the main benefit of Options
>> (composability) while casually discussing practices that are sure to lead to
>> pain (calling get() or pattern matching on the content of an option), and by
>> extension, discourage people from using Option altogether.
>
> You seem to be deliberately clouding the issue.  The side of the fence
> that likes Option and friends like it not because "it forces you to
> deal with null pointers," but because it lets you move the issue into
> the realm of types.  Which is pretty much explicitly why they dislike
> exceptions, because exceptions are pretty much an escape hatch from
> the normal view of the type system.  (Either that, or I am completely
> off in my admittedly naive understanding of the issues.)
>
> What is wrong with pattern matching on the content of an option?  I
> confess I did that just earlier today.  I had a reference to an Object
> that might have been null.  So, I thought the following was fine:
>
> val myRef = something that returns Object for some reason and might be null.
> Option(myRef) match {
>   case Some(x:ClassICanDealWith) => something with x
>   case Some(x:OtherClassICanDealWith => something else with x
>   case _ => either I was null or something I didn't know how to deal with
> }
>
> Was I wrong in that?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/javaposse?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "Java 
Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to