
A Better Way to Launch Quil
TL;DR: wrap `defsketch` in a function. Once again, I overlooked the simplest solution.
Written by: Alex Root-Roatch | Thursday, July 11, 2024
defsketch
Is the One Who Knocks
In a previous post, I talked about my use of load-file
to programmatically launch Quil. I mentioned how Quil launches automatically when the file is evaluated, which is why I chose to use load-file
. However, what I didn't mention was the reason why Quil was launched when the file was evaluated, and that is because defsketch
is the macro that launches Quil. So if I wanted to be able to call Quil just like I would call any function, I simply needed to wrap defsketch
in a function. That would stop Quil from launching everytime the file is evaluated and would make it so Quil only launched when the function containing defsketch
is called.
Easier Testing
A positive side effect of doing this is that Quil no longer automatically launches when I run my tests. Previously, I would have to comment out defsketch
to make sure Quil didn't launch when running tests. Why I didn't think to simply wrap defsketch
in a function at that point rather than commenting it out, I don't know.