On Fri, Jan 6, 2012 at 8:05 PM, Ralf Hemmecke wrote: > Bill Page wrote: >> I think it is unfortunate that as an operator that returns >> Union(...,"failed") the name is irregular. Most such operators have >> names like 'subtractIfCan' with 'IfCan' as a suffix. But 'quoIfCan' >> seems awkward to me and I think it would be nicer to use a single >> character marker similar to ! and ?. A name with a trailing % might >> be suitably mnemonic for such "partial" operators. Then 'quo%' and >> 'subtract%' etc. > > Bill, isn't "operator" in SPAD just standing for an ordinary function that > can be used in infix form? >
I can accept that as the intended meaning this this case. > There is no reason that exquo would have to return Union(..., "failed"). I agree. My comment only concerns the current library convention regarding names that end in 'IfCan'. It just so happens that all except one implementation of exquo in the library does return this sort of Union (aka. Maybe constructor). > For any operator foo one should be able to define something like > > (x: X) foo (y: Y): Z == .... > > for any types X,Y,Z. > > Unfortunately, in SPAD, one still has to write extra parentheses. > > ((x: X) foo (y: Y)): Z == .... > > to get the precedence right. :-( > Yes, although in the current library code overloading is usually avoided in a given context and so separately declaring the type of foo is sufficient. foo: (X,Y)->Z x foo y == ... The question is how to declare an arbitrary name (not already built-in) as such an operator. Any such mechanism has to be outside the Spad language as such so that parsing does not depend on context. It seems strange to build an abbreviation as specific as 'exquo' into the language. But since 'quo' is already built-in I suppose that a name like 'quoIfCan' or 'quo%' might not be unexpected. If it were possible to declare arbitrary names as infix operators then naming could clearly remain as just a library convention. Regards, Bill Page. -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
