Re: textToIntevsal(s) and exceptions
Oliver
On 23 Mar 2015, at 18:22, Oliver Heimlich <oliver@xxxxxxxxxxxxxxxxxxx> wrote:
>> after the definitions of the bare numsToInterval & textToInterval I've put:
>>
>> ===============
>> 1 These constructors shall have decorated versions as follows.
>> 2 – The decorated operation numsToInterval(l,u) has value newDec(x) if the bare operation has value x.
>> 3 – The decorated operation textToInterval(s) has:
>> 4 – value xd if s is a decorated interval literal of the flavor with value xd;
>> 5 – value newDec(x) if s is a bare interval literal of the flavor with value x.
>>
>> 6 A flavor may define extensions of these constructors and/or provide other constructors.
>> 7 ...[Example about Kaucher improper interval, + giving constructor an extra argument like Marco's]
>> ...
>> 8 An implementation may relax at Level 2 the accuracy mode ...
>> ===============
>>
>> Points:
>> - This is only prescriptive about the two standard constructors
>> numsToInterval & textToInterval.
>> - It is short.
>> - It drops the "Otherwise it has no [common] value" stuff.
>> - It explicitly includes promotion of the kind Dmitry put in (line 5).
>> I think it would look weird not to include it.
>> - In line 4 it refers to the sx_sd syntax, hence this is required in all
>> flavors.
>
> Thank you, very good! This makes the standard's requirements clear and reasonable.
>
> One thing that I am missing here: What shall the decorated textToInterval do, if s is an invalid combination x_xd in the flavor (e. g. [1, Inf]_com for set-based intervals)? Or should this be implementation dependent?
Generally flavor-defined, not implementation-defined unless the flavor says so. I think this is covered by 7.5. "The relation of Level 1 to Level 2", in particular 7.5.3 which starts
"For each bare or decorated interval version of an arithmetic operation in 9.1 and for each operation in the rest of Clause 9, a T-version of φ shall be provided for each bare interval type T of the implementation..."
Actually at present it says "9.2 to 9.5" instead of "the rest of Clause 9", that is a typo caused by my putting subclauses of §9 in a different order, it used to say 9.2 to 9.8.
7.5.3 says, if I recall right, that if there is no Level 1 value (which is the case for your invalid combination x_xd) then the flavor might require doing one or more of
- signal UndefinedOperation or in some cases PossiblyUndefinedOperation
- return a flavor-defined value that is considered "reasonable"
Also if the Level 1 value exists but not the Level 2 value
- signal IntvlOverflow.
Or the flavor might leave it implementation-defined which of these to do.
AFAICS, constructors should behave like other operations in this regard. Do you see problems with that? The constructors in the set-based standard conform to 7.5.3 -- I hope and believe.
John Pryce