Ralf Hemmecke wrote:
>
> What I find definitely bad is to give the burden of checking to both the
> function and the caller, by letting the specification be unclear about
> special cases.
>
> http://fricas.github.io/api/GcdDomain.html#l-gcd-domain-gcd
>
> gcd(x, y) returns the greatest common divisor of x and y.
>
> What will gcd(0,0) return in FriCAS?
>
> That it returns 0 is OK with the definition:
>
> d=gcd(a,b) if and only if for all c: c|a and c|b â š c|d.
>
> where
>
> x|y stands for "there exists an integer k such that k*x=y".
>
> I guess most people expect gcd(0,0) to be undefined.
>
> See also https://math.stackexchange.com/questions/495119/what-is-gcd0-0
The last reference explains it quite well: greatest is with
respect to divisibility and the definition gives 0 for gcd(0, 0).
So nothing undefined.
More generaly, when definition has natural and useful extention
going beyond "usual" cases it makes sense to use more general
definition.
To put it differently: sometimes definitions force unnatural
case splits, I prefer to avoid them. OTOH there are natural
case splits and 'children' seem to fall into this category.
BTW: I tolerate double checking to some degree. Namely, it
is easy to place check in 'children' (signaling error), but
logic usualy requires earlier check. Such earlier check
may be easily forgotten and lead to bugs. Check in
'children' would be redundant in correct code, but
in real life helps in finding bugs.
--
Waldek Hebisch
--
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.