[m-rev.] for review: make binary_{input, output}_stream_offset abort on overflow

Zoltan Somogyi zoltan.somogyi at runbox.com
Mon Oct 14 18:12:38 AEDT 2019



On Mon, 14 Oct 2019 18:04:02 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
> >> +    ( if int64.to_int(Offset64, OffsetPrime) then
> >> +        Offset = OffsetPrime
> >> +    else
> >> +        error("io.binary_input_stream_offset: offset exceeds range of an int")
> >> +    ).
> >
> > I think we should use error($pred, "...")  wherever possible.
> 
> Not done, since we currently don't do that in the standard library at
> all. 

That is because most of the standard library predates the addition of $pred
to the language.

> I'm (mostly) not opposed to it, but doing it wholesale would alter
> the contents of most of the standard library exceptions.

Yes, it would, but the formatting of $pred is standard; the formatting
of hand written predicate names is not.

> One reason we
> may not want to do that for the stdlib is that $pred appends the arity
> and sometimes the exception generated is applicable to both the
> predicate and function versions of an operation.

What I meant by "wherever possible" is exactly that we shouldn't do it
in predicates that are not the library entry point that the user called.
If you call predicate x, you don't expect an exception from predicate y,
or even function x, as you say.

But when the call to error is in the interface predicate or function, and that
predicate is not in the call tree of any other interface predicate or function,
then there is no reason not to do it.

Zoltan.


More information about the reviews mailing list