[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] Cycle detection problems: #442, #338, "equal?"
-----BEGIN PGP SIGNED MESSAGE-----
In order to qualify as an equivalence relation, mathematically,
something must be a predicate which is symmetric, reflexive,
and transitive. There are many possible such relations; our
language implements three of them so far. Mathematically a
predicate's range (possible results) are limited to #t and #f.
Results other than #t or #f (which include exception throwing
and infinite looping) expand the domain of the function, which
means that a function is not in fact a predicate.
I'm aware that code isn't really mathematics, but I'd like to
argue that on the grounds of mathematical correctness, a loop-
detecting equality function that checks and reports the equality
of loops is a predicate. A loop-blind equality function which
can diverge is not a predicate. An equality function which can
throw an error or exception is not a predicate. Both may run
faster in some cases and both may be useful for some purposes,
but I support the notion that equivalence relations should actually
be predicates in the mathematical sense. It makes some things
easier to reason about, and reduces the number of cases the
programmer has to consider.
Also, both divergence and exceptions are side effects. As someone
who prefers a functional programming style, I like to avoid them
and avoid writing code that has to consider them.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
Scheme-reports mailing list