Re: More on flavor conversions (was:Re: Revised FlavorsText)
Folk
On 2014 Mar 18, at 09:57, Hossam A. H. Fahmy wrote:
> I agree with George. The text seems to be well written and covers the
> intended purpose.
> George wrote:
>> Sounds OK to me.
Grand. What about the "which flavor is in force" aspect, i.e. is conversion an import or an export function? I still feel import is more natural. However, whichever way, it seems to raise programming problems. Suppose: we have a strongly typed language; the interval implementation is provided by one or more libraries; and there are flavors, say, F1 = set-based and F2 = Kaucher.
Enforcing "one flavor at a time" should be doable by having an F1 library L1, and an F2 library L2, which use identical sets of external names for functions at link-time. But if one compilation unit C1 of a whole program wants to use F1 and another unit C2 wants to use F2, can one direct the linker to use L1 for C1 and L2 for C2? (A practical problem about linker switches, not a conceptual one.)
Suppose one can, suppose now C1 wants to reference an interval xx2 of some F2-type T2, to convert it to an xx1 of some F1-type T1. How to code it? I presume xx2 can't be defined within C1, which only can create F1 objects; so it must be "static" in C parlance. But when compiling C1, there must be information available (in a .h file?) to say what kind of object xx2 is. Will that work? AFAICS Fortran poses a similar problem.
In a weakly typed language such as Matlab, the "one flavor at a time" rule is unenforceable: each interval object knows its own type, and it's the despatch rules of the language that prevent mixed-flavor operations. In fact the conversion problem seems to disappear here, as it's easy to write a conversion function xx1 = convertToT1inF1(xx) that can take xx of a variety of flavors/types if desired. Not massively efficient, but always correctly despatched.
Advice please
John Pryce
> On Mar 18, 2014, at 2:38 AM, John Pryce <j.d.pryce@xxxxxxxxxx> wrote:
>> I wrote:
>>> It seems that somehow inter-flavor conversion functions were forgotten.
>>
>> Trying to write text, I found it really needs to go later than 7.1, so I suggest putting it in a new sub-subclause before the current 7.5.4 "Measures of accuracy". How about this?
>>
>>> 7.5.4. Inter-flavor conversion. If an implementation provides more than one flavor, it shall provide conversions between them. For any two flavors F_1 and F_2, it shall define those Level 1 F_1-intervals x_1 and F_2-intervals x_2 that are regarded as equal. Mutual conversion shall be provided for at least one pair of types T_1 of F_1 and T_2 of F_2. That is, each T_1-interval x_1 maps to a T_2-interval that encloses the F_2-interval x_2 that equals the Level 1 value of x_1, if x_2 exists. If it does not exist, or no T_2-enclosure can be found, the UndefinedOperation exception is signaled. The same applies with T_1 and T_2 interchanged.
>>
>> John Pryce