Here's an implementation to try:
https://github.com/racket/racket/pull/1689
So far, I like "authentic" better than the alternatives, so the PR uses
that term.
If you try something like
(struct posn (x y))
(time
(let ([p (posn 1 -1)])
(for/fold ([n 0]) ([i (in-range 100000000)])
(+ (+ n (posn-x p)) (posn-y p)))))
then the difference with `#:authentic` is in the noise. But with an
example that involves more code, as below, then you can see a 5-10%
overall effect (even though the number of relevant field accesses is
the same).
----------------------------------------
#lang racket/base
(require (for-syntax racket/base))
(struct posn (x y)
#:authentic)
(define-syntax (dispatch stx)
(syntax-case stx ()
[(_ e body)
(let ([bits 5]) ; <- determines amount of code
(with-syntax ([(c ...) (for/list ([i (expt 2 bits)])
i)]
[mask (sub1 (expt 2 bits))])
#'(case (bitwise-and e mask)
[(c) body] ...)))]))
(time
(let ([p (posn 1 -1)])
(for/fold ([n 0]) ([i (in-range 100000000)])
(dispatch
i
(+ (+ n (posn-x p)) (posn-y p))))))
--
You received this message because you are subscribed to the Google Groups
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-dev/5915d380.c431620a.fbc10.6a49SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.