-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sep 1, 2006, at 7:15 AM, Will M Farr wrote:

Hello all,

On Sep 1, 2006, at 3:06 AM, Kon Lovett wrote:

<snip>
3. My opinion is that The Right Thing (TM) is to code the macro as follows:

(define-syntax do-range
  (syntax-rules ()
    ((_ (i aa bb) expr ...)
     (let ((a aa)
           (b bb))
       (cond-expand
        ((not unsafe)
         (if (or (not (fixnum? a))
                 (not (fixnum? b)))
             (error 'do-range "non-fixnum limits" a b))))
       (do ((i a (fx+ i 1)))
           ((fx= i b))
         expr ...)))))

This works, but it's pretty yucky. It is the simplest way, given the present behavior of the fxXXX operators, to achieve safety in safe mode (with useful, and immediate, error reporting) and speed in unsafe mode. I submitted the fixnum patch because it would implement the same behavior, but without requiring people using the fxXXX operators to think so much about these issues (and type (cond- expand ...) every time).

Perhaps this situation is familiar to other Chicken users, but I didn't realize that something like #3 was needed to be both safe and fast until yesterday. This is just food for thought---I understand if felix and others want to keep the present behavior of the fxXXX operators.

Good food. (Made me think to re-visit some older code that had some ASSumptions about the public interface arguments.)

But Felix's point about 'ensure' should help w/ syntax forms that have domain & range restrictions.

Best wishes,
Kon


Will

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iEYEARECAAYFAkT4StUACgkQJJNoeGe+5O4PPQCfXr70oMy9Ib+evIMf1H0Sj3UV
99AAnjye5hn+dHxo5RAIBtSuqX83EGtT
=jTMq
-----END PGP SIGNATURE-----


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to