[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [PATCH] Small types.db fixes and some notes/questions
From: |
Peter Bex |
Subject: |
[Chicken-hackers] [PATCH] Small types.db fixes and some notes/questions |
Date: |
Sat, 21 Apr 2012 00:36:28 +0200 |
User-agent: |
Mutt/1.4.2.3i |
Hi,
I've found a few numbers-related problems in the types database.
The finite?, exact? and inexact? procedures were marked as being pure
predicates accepting any type of input. They were also rewritten to C
functions that always return a boolean value, but all three raise a
type error in the interpreter when called with non-number values.
Of course, that results in an annoying inconsistency between compiled
code and interpreted code (where the latter gives an error while the
former does not).
The patch adds a few more tests (and moves the assert-fail definition
to the top so that they can be added at the most logical place)
Unfortunately, this gets rid of the warning messages when you pass
a number that's already known to be exact or inexact to exact?/inexact?,
but I think that's not too big a loss.
Some notes/questions:
- Maybe the C functions C_inexactp and such should be the ones that raise
the exception, rather than the Scheme code? I don't know where else
they are used or what's most consistent/clean.
- The rewrites in c-platform.scm seem kind of redundant with the rewrites
done by the scrutinizer and possibly wrong for these cases too, so
another potential hiding place for many bugs.
Now that we have the scrutinizer I think they can probably be removed
altogether without loss of performance in compiled code. This should
also result in faster compilation times since the rewriting code seems
rather complicated too (and it's hard to understand, so getting rid of
it is probably a good idea maintenance-wise too).
I'm just not sure whether all functionality is truly duplicated in
types.db. Of course if we remove it, this should wait until after
4.8.0 is released.
- I noticed that with -O4, the following code passes cleanly:
(define-syntax assert-fail
(syntax-rules ()
((_ exp) (assert (handle-exceptions ex #t exp #f)))))
(assert (exact? 1))
(assert (not (exact? 1)))
(assert-fail (exact? 1))
Could someone explain how this is possible? -debug o didn't
really help, nor did ripping the rewrites from c-platform.scm
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
0001-Two-types.db-fixes.patch
Description: Text document
- [Chicken-hackers] [PATCH] Small types.db fixes and some notes/questions,
Peter Bex <=