Stream: helpdesk (published)

Topic: @generated functions workflow


view this post on Zulip James Wrigley (Mar 06 2023 at 17:14):

My usual workflow for writing/debugging functions is to write a test case for them and then iterate until it does what I want, but I recently wrote a @generated function and that approach isn't working so well. Revise can't always handle changes to @generated functions (https://timholy.github.io/Revise.jl/stable/limitations/#Macros-and-generated-functions-1) so if I'm playing around in the REPL I call revise(MyModule) and that works fine, but I can't find a way to trigger that in the test process. So if I run MyModuleTests.retest(), change the code, and run the tests again, the old function will be used.

How do you all deal with that? In this case I could rewrite it as a couple of regular functions but it'd be nice not to.

view this post on Zulip chriselrod (Mar 06 2023 at 17:59):

I do think regular functions should generally be preferred, but I manually change the body of the @generated function itself whenever I want to revise it, e.g. by commenting/uncommenting a useless line like 1+1.

view this post on Zulip James Wrigley (Mar 06 2023 at 18:12):

Nice, that works :thumbs_up:

view this post on Zulip chriselrod (Mar 06 2023 at 21:48):

Maybe I shouldn't commit that into a repo https://github.com/JuliaSIMD/LoopVectorization.jl/blob/099630805b8d50c40d0b2a5f4f3a6775b01f5a9a/src/reconstruct_loopset.jl#L1185 lol


Last updated: Oct 02 2023 at 04:34 UTC