> to replace with something that cannot be caught, but for this one I cannot > suggest a use case (maybe writing way past array boundaries when using > @inbounds?) >
Maybe a better example for something that should not be possible to catch is an assertion error. > > > On Sat, Aug 22, 2015 at 5:06 PM, Stefan Karpinski <ste...@karpinski.org> > wrote: > >> No worries, if you've got any bright ideas how we should resolve this >> throw/error thing... >> >> On Sat, Aug 22, 2015 at 7:06 AM, Michele Zaffalon < >> michele.zaffa...@gmail.com> wrote: >> >>> You are right, my reply was unnecessary. >>> >>> On Sat, Aug 22, 2015 at 10:14 AM, Stefan Karpinski <ste...@karpinski.org >>> > wrote: >>> >>>> Not sure how that's really a response to what I said, which >>>> acknowledges that it's an ambiguity... >>>> >>>> On Sat, Aug 22, 2015 at 12:58 AM, Michele Zaffalon < >>>> michele.zaffa...@gmail.com> wrote: >>>> >>>>> Verbosity aside, (which may also be disputable since errors are >>>>> supposed to be rare...), I still do not see the difference even from >>>>> reading the constructed examples in the manual: both are examples of >>>>> functions that are not defined for negative arguments, but in the first >>>>> case, the function throws an exception, in the second it signals an error. >>>>> michele >>>>> >>>>> On Fri, Aug 21, 2015 at 6:06 PM, Stefan Karpinski < >>>>> ste...@karpinski.org> wrote: >>>>> >>>>>> This is actually an old debate between me and Jeff. The distinction I >>>>>> tried to make was that `throw` should be used with catch as a form of >>>>>> control flow, while `error` should be used when there's an actual error. >>>>>> However, that distinction hasn't stuck, possibly because he never liked >>>>>> it >>>>>> and it's common to see `throw(InexactError())` in Base. We could get rid >>>>>> of >>>>>> `error` but writing `throw(ErrorException("oops"))` to throw a simple >>>>>> error >>>>>> seems pretty unpalatable. >>>>>> >>>>>> On Fri, Aug 21, 2015 at 11:53 AM, Isaiah Norton < >>>>>> isaiah.nor...@gmail.com> wrote: >>>>>> >>>>>>> Yes. >>>>>>> >>>>>>> On Fri, Aug 21, 2015 at 11:51 AM, Michele Zaffalon < >>>>>>> michele.zaffa...@gmail.com> wrote: >>>>>>> >>>>>>>> That is my point: error is the same as throw(ErrorException). >>>>>>>> Should both co-exist? Is error just a short name for the >>>>>>>> throw(ErrorException) version? >>>>>>>> >>>>>>>> On Fri, Aug 21, 2015 at 5:43 PM, Isaiah Norton < >>>>>>>> isaiah.nor...@gmail.com> wrote: >>>>>>>> >>>>>>>>> `error` is generic, whereas `throw` can raise typed errors, such >>>>>>>>> as DomainError, SimdError, UVError, etc. which may have special >>>>>>>>> handling -- >>>>>>>>> for example, customized `show` methods to print help/suggestions to >>>>>>>>> resolve >>>>>>>>> the specific situation. >>>>>>>>> >>>>>>>>> (see also the examples here: >>>>>>>>> http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-try-catch-statement >>>>>>>>> ) >>>>>>>>> >>>>>>>>> On Fri, Aug 21, 2015 at 11:32 AM, Michele Zaffalon < >>>>>>>>> michele.zaffa...@gmail.com> wrote: >>>>>>>>> >>>>>>>>>> In what cases should one use error() instead of throw()? The >>>>>>>>>> manual >>>>>>>>>> <http://docs.julialang.org/en/latest/manual/control-flow/?highlight=error#the-throw-function> >>>>>>>>>> is not particular clear about the difference: >>>>>>>>>> >>>>>>>>>> The error() function is used to produce an ErrorException that >>>>>>>>>> interrupts the normal flow of control. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Isn't what throw is supposed to do? >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> >