chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] fixnum-specific math operators patch


From: Kon Lovett
Subject: Re: [Chicken-users] fixnum-specific math operators patch
Date: Fri, 1 Sep 2006 10:59:33 -0700

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

On Sep 1, 2006, at 9:42 AM, Will M Farr wrote:

Kon (and others),

On Sep 1, 2006, at 10:59 AM, Kon Lovett wrote:

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

Yeah---that would be The Right Way (TM). (And it allows for more situation-adapted tests.)

By the way (maybe felix can answer this), if I define a structure with

(define-record foo bar baz)

does it define the accessors and setters as

(define (foo-bar f)
  (ensure foo? f)
  (block-ref f 0))

Sort of. Doesn't use 'ensure'. The type-check is always performed, but inline 'C'.

You can see what it makes in csi:

#;49> ,x (define-record a b c)
(begin
  (define make-a (lambda (b c) (##sys#make-structure 'a b c)))
  (define a? (lambda (x) (##sys#structure? x 'a)))
  (begin
    (define a-b-set!
(lambda (x val) (##sys#check-structure x 'a) (##sys#block-set! x 1 val)))
    (define a-b
      (lambda (x) (##sys#check-structure x 'a) (##sys#block-ref x 1))))
  (begin
    (define a-c-set!
(lambda (x val) (##sys#check-structure x 'a) (##sys#block-set! x 2 val)))
    (define a-c
(lambda (x) (##sys#check-structure x 'a) (##sys#block-ref x 2)))))

The 'misc-extn' egg has versions of SRFI-9 'define-record-type' which DO NOT perform
these type checks.

...

I'm curious because I've read in other places (one of Manuel Serrano's papers on type inference) that type checks can take up a large fraction of the runtime, and it would be nice to eliminate as many as possible in (unsafe) code.

Will

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

iEYEARECAAYFAkT4dQUACgkQJJNoeGe+5O6JXACggTG3a/xQmpcFVKIpnAg22JOS
uNkAn3Nhm1Qyo4DFqfJJMWREx+Nnj70R
=/LjY
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]