source: project/wiki/usual-integrations-and-let @ 36676

Last change on this file since 36676 was 5492, checked in by Jim Ursetto, 12 years ago

Changes applied for zbigniew (67.167.53.235) through svnwiki:

usual-integrations-and-let code snippet

File size: 1.5 KB
Line 
1 ;; test why when usual-integrations is in effect, rebinding list->vector seems
2 ;; to cause a procedure lookup in BINARY-SEARCH in extras.scm
3 ;; compile: csc -t usual.scm
4 ;; by zb
5 
6 ;; result: LET is a win for external procedures not covered by usual-integrations.
7 ;; LET is a lose for usual-integrations, as it disables certain optimizations.
8 ;; The latter is the case with binary-search and is probably a holdover
9 ;; from pre-usual-integrations days.
10 
11 ;(declare (not usual-integrations list->vector))
12 
13 ;; findings: both calls to list->vector are looked up with C_retrieve_proc
14 ;; the effective call is C_cons(C_retrieve_proc(x)(C_list(3,1,2,3))
15 ;;                              C_retrieve_proc(x)(C_list(3,4,5,6)))
16 ;; the global binding is only looked up once via C_intern and
17 ;; stored in the closure.  adding -O2 has no effect.
18 ;;
19 ;; with (not usual-integrations list->vector), a C_retrieve() is done only once
20 ;; when foo is mutated with the closure, and thereafter a single C_retrieve_proc
21 ;; for every call of list->vector.
22 (define foo
23   (let ((list->vector list->vector))
24     (lambda ()
25       (cons (list->vector '(1 2 3))
26             (list->vector '(4 5 6))))))
27 
28 ;; findings: with usual-integrations, the list->vector is done at compile time,
29 ;; so the call is [pseudocode] C_cons(C_vector(3,1,2,3), C_vector(3,4,5,6))
30 ;;
31 ;; with (not usual-integrations list->vector), a C_retrieve() and a C_retrieve_proc
32 ;; are done on every call.
33 (define bar
34   (lambda ()
35     (cons (list->vector '(1 2 3))
36           (list->vector '(4 5 6)))))
Note: See TracBrowser for help on using the repository browser.