Magma provides two equality operators: eq for strong (comparable) equality testing, and cmpeq for weak equality testing. The operators depend on the concept of comparability. Objects x and y in Magma are said to be comparable if both of the following points hold:
If x and y are comparable, return whether x equals y (which will always work by the second rule above). If x and y are not comparable, an error results.
If x and y are comparable, return whether x equals y. Otherwise, return false. Thus this operator always returns a value and an error never results. It is useful when comparing two objects of completely different types where it is desired that no error can happen. However, it is strongly recommended that eq is usually used to allow Magma to pick up common unintentional type errors.
> 1 eq 2/2; true > 1 cmpeq 2/2; true > 1 eq "x"; Runtime error in 'eq': Bad argument types > 1 cmpeq "x"; false > [1] eq ["x"]; Runtime error in 'eq': Incompatible sequences > [1] cmpeq ["x"]; false