[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-----
Hash: SHA1


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.

				Bear
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJQPuuGAAoJEAOzWkqOibfNW7MIAJJqERJabbW7VsV44SJSa/to
t1OWDBR6kuuw2xv0E201JAn2znZPf/i8prgKDFbv5kLupAhR5WIUQgywPyLpRmzE
Mz7I/UJNPvb4OFyl8AOle78b+0VBI5hkJTfLSRCHcVdfxDJNlO3qHYQVpewg76LL
m2yg7BL7Ce1y1nAEcnX+/W+i6LYtWC9m5xHdK67FJwDc/tUTRNoIEgpEBwG9z4Z7
CkkpE8pb994Ui9rWE64XtkbhEdPhIQwaE1XZzCMIYjrGxJXrCRvx/LmTX+nbv48I
gMqMb+kakVMRgX2JWoZi5a11LTU7dzTvnXo4E1Ybqe1+DwXa+JVWVoHibDBWMHY=
=v23q
-----END PGP SIGNATURE-----

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports