Re: P1788 input/output
On 2013-07-23 06:49:24 -0400, Michel Hack wrote:
> Vincent Lefèvre replied to my note on intervalTo Recoverable():
> > The primary goal of recovery is to use the same type. Then there's the
> > question of whether you want to allow exact2interval to be applied on a
> > different type. If yes, then I agree that one needs to require an exact
> > representation. For instance, if exact2interval is applied on a different
> > type, it shall either return an exact result or raise a language- or
> > implementation-defined exception.
>
> This is possible only if the recoverable representation includes type
> information.
No, in either case, you don't need to record type information.
* If just recoverable is chosen, the user is assumed to know the type
(just like when he uses a function, he needs to know the prototype).
* If exact representation is chosen, type information is useless
as the representation is exact, so that its meaning is known for
every type (but some types may not be able to use it exactly).
I agree that it is less error-prone.
> And the issue of deliberate containment violation in one
> or the other direction remains: warnings about mis-use would be needed.
Yes.
> One way would be for the type encoding to be such that the result is
> syntactically invalid for textToInterval(), so that it can be read back
> successfully only through recoverableToInterval() to a matching format,
> as Vincent suggested above (but I would not call it "exactToInterval()").
Yes.
But note that there should also be warnings for the "[x]" form.
It can also easily be mis-used.
> The nice thing about intervalToExact() is that its result can be read
> back by regular textToInterval(), recovering the original type exactly,
> but preserving containment in all cases, in and out. There is no need
> for extra information.
I agree.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)