This isn't about Scala;  I just copy/pasted what I'd previously written out
of sheer laziness :)

I'll repeat the same code in Java, and still give you all the wanted
qualities (except the one about having an easier syntax than Java, that
would be somewhat difficult)

    //using try/catch
    try {
        FileHandle handle = fileOpen(fileName);
        doSomethingWithFile(handle);
    } catch (FileNotFoundException e) {
        ...
    } catch (IOException e) {
        ...
    } catch (Exception e) {
        ...
    } catch (throwable e) {
        ...
    }

So you have pattern matching (of a sort), and it can be easily used from any
stack frame (so long as you drop the requirement of checked exceptions)


2010/9/22 Cédric Beust ♔ <[email protected]>

>
>
> On Wed, Sep 22, 2010 at 9:30 AM, Kevin Wright <[email protected]>wrote:
>
>>
>>
>> 2010/9/22 Cédric Beust ♔ <[email protected]>
>>
>>>
>>>
>>> On Wed, Sep 22, 2010 at 8:19 AM, Kevin Wright 
>>> <[email protected]>wrote:
>>>
>>>> Instead, a language can offer exhaustive pattern matches in a range of
>>>> other, non-exceptional scenarios, so offering the best of both worlds.
>>>
>>>
>>> In my opinion, the best of both worlds would be being able to handle
>>> exceptions in any stack frame with an easier syntax than Java's current one,
>>> possibly with pattern matching on the exception type. Unfortunately, no
>>> language supports both this and checked exceptions today.
>>>
>>>
>> Sure it does, if I widen my previous code a little:
>>
>
> I know you never miss an opportunity to post Scala code, but please, read
> my posts a little bit more carefully, I specifically mentioned checked
> exceptions, so I stand by my claim: no language supports these two features
> today.
>
> --
> Cédric
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<javaposse%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>



-- 
Kevin Wright

mail / gtalk / msn : [email protected]
pulse / skype: kev.lee.wright
twitter: @thecoda

-- 
You received this message because you are subscribed to the Google Groups "The 
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