On 09/26/2017 12:27 PM, oldk1331 wrote: >> Really? Yes, it can, but it is a matter of specification. If you declare >> that retract(x) is only applicable if not(failed?(x)) holds, then there >> is no need for an additional error checking. Such error checking would >> only be a safety net, but not necessary by specification. > > 'retract' should always check for error, if doesn't check for error, > it should be given a different name.
Arrhhh... you seem to be right. :-( http://fricas.github.io/api/RetractableFrom http://fricas.github.io/api/RetractableTo retract: % -> S retract(a) transforms a into an element of S if possible. Error: if a cannot be made into an element of S. BUT... What exactly does that "Error" above actually mean? Does it mean that the programm checks whether a is indeed an element of S? I claim that this specification is rather unclear. I would rather add a function retractable?: % -> Boolean that does exactly such a check and transform the specification into: retract(x) transforms x into an element of S if retractable?(x) holds. It is an error to call retract(x) for elements for which retractable?(x) does not hold. In fact, currently (with error checking) retract is not a total, but a partial function. I would like to still have the type % -> S, but restrict the input set to elements of % for which retractable?(x) holds and in this sense make it a total function on this restricted set (which is a partial function on %). I'd be actually happier if -> only denotes total functions and we could express partial functions in another way. Best would be to annotate the input type, for example retract: retractable?(%) -> S meaning only those elements x of % for which retractable?(x) holds. The compiler could treat retractable?(%) like % (i.e., ignoring this annotation), but for the programmer it would be clearer that not every element of % can be taken as input. Ralf -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
