# Compile time for unused functions might take very long time

**URL:** <https://racket.discourse.group/t/compile-time-for-unused-functions-might-take-very-long-time/3013>\
**Category:** Questions & Answers\
**Tags:** question\
**Created:** [July 10, 2024, 8:45am UTC](https://racket.discourse.group/t/compile-time-for-unused-functions-might-take-very-long-time/3013 "2024-07-10T08:45:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hakank/32/1838_2.png) [@hakank](https://racket.discourse.group/u/hakank)\
**Post date:** [July 10, 2024, 8:45am UTC](https://racket.discourse.group/t/compile-time-for-unused-functions-might-take-very-long-time/3013/1 "2024-07-10T08:45:13Z")

</div>

I'm a Racket newbie and this is perhaps a common question, but I haven't found any answers on this.

Here's a simple function just returning a large list:

```scheme
(define slow-test
  (range 1 100000000))

(writeln "after")

```

Note that the function is not called. However, it takes a lot of time when running this program. Running it in DrRacket creates a lot of "Interactions disabled; out of memory" (and offers to increase the memory). Running the program from command line give the same behavior (but no out of memory errors) and it takes about 13s to run.

I am assuming that it has something to do with how Racket reads and compiles functions. Is there some a way of avoiding this behavior (apart from commenting the unused function definitions)?

Environment:

- Racket v8.3
- Linux Ubuntu 20.05

Best,

Hakan

---

<div class="post-metadata">

**Author:** ![shawnw](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/shawnw/32/1031_2.png) [@shawnw](https://racket.discourse.group/u/shawnw)\
**Post date:** [July 10, 2024, 9:46am UTC](https://racket.discourse.group/t/compile-time-for-unused-functions-might-take-very-long-time/3013/2 "2024-07-10T09:46:18Z")

</div>

```scheme
(define slow-test
  (range 1 100000000))

```

That's not a function definition. You're setting the variable `slow-test` to the result of `(range 1 100000000)`, which is a very large list that takes time and a lot of memory allocations to create. If it were a function, it might look like

```scheme
(define (slow-test)
  (range 1 100000000))

```

or

```scheme
(define slow-test
  (lambda () (range 1 100000000)))

```

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hakank/32/1838_2.png) [@hakank](https://racket.discourse.group/u/hakank)\
**Post date:** [July 10, 2024, 10:10am UTC](https://racket.discourse.group/t/compile-time-for-unused-functions-might-take-very-long-time/3013/3 "2024-07-10T10:10:40Z")

</div>

Thanks! That explains everything.

(It has probably been too much Common Lisp lately. 🙂 )
