Passing command line arguments at compile-time?

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

(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!

1 Like

So, it appears the solution was as simple as:

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

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

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.

1 Like