# Can compiled and uncompiled versions of a single function exist in a collection?

**URL:** <https://racket.discourse.group/t/can-compiled-and-uncompiled-versions-of-a-single-function-exist-in-a-collection/564>\
**Category:** Questions & Answers\
**Created:** [January 13, 2022, 11:14am UTC](https://racket.discourse.group/t/can-compiled-and-uncompiled-versions-of-a-single-function-exist-in-a-collection/564 "2022-01-13T11:14:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fyrbll](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@Fyrbll](https://racket.discourse.group/u/Fyrbll)\
**Post date:** [January 13, 2022, 11:14am UTC](https://racket.discourse.group/t/can-compiled-and-uncompiled-versions-of-a-single-function-exist-in-a-collection/564/1 "2022-01-13T11:14:40Z")

</div>

Suppose

- I install a collection via `raco pkg install`.
- I add a `printf` to the body of one function within the collection that's called at various places in the same collection.
- I _don't_ run `raco setup` after modifying the function.

At this point could it be that some calls to the function in the collection are actually calls to an older, compiled version while others are calls to the new, uncompiled version?

---

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [January 15, 2022, 12:58am UTC](https://racket.discourse.group/t/can-compiled-and-uncompiled-versions-of-a-single-function-exist-in-a-collection/564/2 "2022-01-15T00:58:22Z")

</div>

No, I believe it should be the case that all calls are made to the new version of the function. Do you have an example where this doesn't appear to be the case?

---

<div class="post-metadata">

**Author:** ![Fyrbll](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@Fyrbll](https://racket.discourse.group/u/Fyrbll)\
**Post date:** [January 18, 2022, 7:33pm UTC](https://racket.discourse.group/t/can-compiled-and-uncompiled-versions-of-a-single-function-exist-in-a-collection/564/3 "2022-01-18T19:33:07Z")

</div>

I'm using Racket v8.3 [cs] on Linux 5.4 on Chrome OS.

Here's a specific example.

1. Perform a fresh install of the `typed-racket-lib` package using `raco`

2. Make the changes marked with `New` to the file  
`typed-racket-lib/typed-racket/env/global-env.rkt`

```scheme
;; free-id-table from id -> type or Box[type]
;; where id is a variable, and type is the type of the variable
;; if the result is a box, then the type has not actually been defined, just registered
(define the-mapping (make-free-id-table))

;; ~~~~~New~~~~~
(printf "Size of the-mapping is ~a~n"
        (free-id-table-count the-mapping))

(define register-type-first-call? #t)
;; ~~~~~~~~~~~~~~~

;; add a single type to the mapping
;; identifier type -> void
(define (register-type id type)
  ;; ~~~~~New~~~~~
  (when register-type-first-call?
    (printf "Size of the-mapping is ~a~n"
        (free-id-table-count the-mapping))
    (set! register-type-first-call? #f))
  ;; ~~~~~~~~~~~~~~~
  (free-id-table-set! the-mapping id type))

```

1. Run this code.

```scheme
#lang typed/racket/base
    
(define-type Z Integer)

```

Check the output.

```scheme
Size of the-mapping is 0
Size of the-mapping is 146

```

If we assume that `register-type` is the only way to grow `the-mapping` then it looks like a bunch of `printf` statements didn't fire.

1. Modify the file `typed-racket-lib/typed-racket/typecheck/tc-structs.rkt`. Add this line immediately after the `provide` block at the start of the file and before `(define-syntax-class parent ...)`

```scheme
(printf "I'm in tc-structs.rkt~n")

```

1. Run the program from Step 3 again. This time the output is:

```scheme
Size of the-mapping is 0
I'm in tc-structs.rkt
Size of the-mapping is 0

```

I suspect that during Step 3, calls to `register-type` in `tc-structs.rkt` - such as in the function `tc/builtin-struct` - actually referred to a compiled version of the old `register-type` function. One without the `printf`.
