The Philosophy of Nothing
Dimitris Andreou
jim.andreou at gmail.com
Wed Dec 2 08:33:09 PST 2009
2009/12/2 Paul Benedict <pbenedict at apache.org>:
> Neal,
>
> On Wed, Dec 2, 2009 at 10:07 AM, Neal Gafter <neal at gafter.com> wrote:
>> On Wed, Dec 2, 2009 at 7:59 AM, Paul Benedict <pbenedict at apache.org> wrote:
>>>
>>> Does the spec prevent defining method that can neither return nor throw?
>>>
>>> public Nothing func() throws Nothing { }
>>
>> No, because Java has unchecked exceptions, and for other reasons that will
>> be more clear when part b (0.6b) is published.
>>
>> I can't imagine what the value would be of adding such restrictions to the
>> specification or compiler.
>
> If a method cannot return nor throw, I would expect this to be an
> obvious compilation error. Note this example has nothing to do with
> closures, but just a normal method declaration.
>
> Well, I'll have to be patient and wait for 0.6b to explain. I am
> hoping that Nothing is used consistently. Thanks, Neal.
>
> Paul
>
Hi Paul,
Note that a method can still throw exceptions it does not declare. But
even if a method was required to list all possible thrown exceptions
in its "throws clause", and it only declared Nothing so it couldn't
throw any exceptions, then still this shouldn't be a compilation
error, the code could simply enter an infinite loop.
Dimitris
More information about the closures-dev
mailing list