# Passing command line arguments at compile-time?

**URL:** <https://racket.discourse.group/t/passing-command-line-arguments-at-compile-time/2368>\
**Category:** Questions & Answers\
**Created:** [October 5, 2023, 9:31pm UTC](https://racket.discourse.group/t/passing-command-line-arguments-at-compile-time/2368 "2023-10-05T21:31:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rscho](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/rscho/32/726_2.png) [@rscho](https://racket.discourse.group/u/rscho)\
**Post date:** [October 5, 2023, 9:31pm UTC](https://racket.discourse.group/t/passing-command-line-arguments-at-compile-time/2368/1 "2023-10-05T21:31:30Z")

</div>

Hi,

I am writing a kind of constraint solver for a combinatorics problem involving bignums.  
The single best optimization I can perform is of course pruning the solution space as early as possible. So, I thought about injecting a list of numeric constraints into the code at compile-time through macros, because defining constraints at runtime would mean lots of branching in hot loops of the kind

```scheme
(if (constraint current-combination)
  (keep current-combination)
  (discard current-combination))

```

How can I invoke racket with something like

`$ racket solver.rkt constraint_a constraint_b ...`

such that the argument constraints can be used at compile-time in `solver.rkt` macros to direct code generation and avoid checking the constraints at run-time?

Thanks!

---

<div class="post-metadata">

**Author:** ![rscho](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/rscho/32/726_2.png) [@rscho](https://racket.discourse.group/u/rscho)\
**Post date:** [October 7, 2023, 9:25am UTC](https://racket.discourse.group/t/passing-command-line-arguments-at-compile-time/2368/2 "2023-10-07T09:25:38Z")

</div>

So, it appears the solution was as simple as:

```scheme
(begin-for-syntax (command-line ...))

```

Which then allows for using the command-line arguments at compile-time. 😃

---

<div class="post-metadata">

**Author:** ![sorawee](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sorawee](https://racket.discourse.group/u/sorawee)\
**Post date:** [October 7, 2023, 1:48pm UTC](https://racket.discourse.group/t/passing-command-line-arguments-at-compile-time/2368/3 "2023-10-07T13:48:02Z")

</div>

You might be interested in my StackOverflow question and Leif’s answer, which details a caveat that if you precompile your program via `raco make`, you might not get an expected result in a later run: [-D option and #ifdef in Racket](https://stackoverflow.com/q/41414895/718349).
