The evaluation of u occurs outside the scope of try. so the value
error is not caught:
adverse=:2 :0
try.u y catcht.v y end.
:
try.x u y catcht.x v y end.
)
throwAnException adverse ('caught you!'"_) ''
|value error: throwAnException
| u y
throwAnException :: ('caught you!'"_) ''
caught you!
I have not found an easy way to test for value errors alone, as
opposed to the easy use of :: to catch all errors. I haven't put much
effort into that, however.
On Thu, Sep 10, 2009 at 8:33 AM, Raul Miller <[email protected]> wrote:
> On Thu, Sep 10, 2009 at 11:24 AM, Matthew Brand
> <[email protected]> wrote:
>> :: (adverse) catches errors but not throws. Is there a way to catch a
>> throw in a tacit expression?
>
> Conceptually speaking, a throw requires an explicit expression:
> you can not generate throws without using an explicit expression
> to generate it.
>
> Similarly, you can write your own "adverse" style conjunction
> which evaluates a verb and if it generates a throw evaluates
> some other verb. The implementation of this conjunction
> would be explicit, but if you are already dealing with a throw
> that should not be an obstacle for you.
>
> In other words something like this (but I have not tested it):
>
> adverse=:2 :0
> try.u y catcht.v y end.
> :
> try.x u y catcht.x v y end.
> )
>
>
> throwAnException adverse ('caught you!"_) ''
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm