Replies: 2 comments 2 replies
-
So turns out this is because of the way Julia seems to do the macro "hygiene" stuff. This is "fine" when you use In my testing I found no way to work around it, other than explicitly I'll open an issue on Julia for this... |
Beta Was this translation helpful? Give feedback.
-
As a workaround for the Julia issue I built a small package (Hygienic.jl) that can hygienize the quote returned by the macro: using Hygienic
julia> @hygienize quote
rerun_cell_fn = @give_me_rerun_cell_function()
state_ref = @use_ref()
set_state = (new) -> begin
new_value = if hasmethod(new, Tuple{typeof(new)})
new(state_ref[])
else
new
end
state_ref[] = new_value
rerun_cell_fn()
end
(state_ref[], set_state)
end
quote
#= REPL[5]:2 =#
var"##rerun_cell_fn#284" = #= REPL[5]:2 =# @give_me_rerun_cell_function()
#= REPL[5]:3 =#
var"##state_ref#285" = #= REPL[5]:3 =# @use_ref()
#= REPL[5]:4 =#
var"##set_state#288" = (var"##new#286"->begin
#= REPL[5]:4 =#
#= REPL[5]:5 =#
var"##new_value#287" = if hasmethod(var"##new#286", Tuple{typeof(var"##new#286")})
#= REPL[5]:6 =#
var"##new#286"(var"##state_ref#285"[])
else
#= REPL[5]:8 =#
var"##new#286"
end
#= REPL[5]:11 =#
var"##state_ref#285"[] = var"##new_value#287"
#= REPL[5]:12 =#
var"##rerun_cell_fn#284"()
end)
#= REPL[5]:14 =#
(var"##state_ref#285"[], var"##set_state#288")
end |
Beta Was this translation helpful? Give feedback.
-
The following works great, I use a channel to link values into a magic cell (not useful in this MWE):
Schermopname.2021-11-17.om.21.57.28.mov
But 💔
when I put this functionality into a macro (
@huh
), theset_state
has no effect:Schermopname.2021-11-17.om.21.55.04.mov
Beta Was this translation helpful? Give feedback.
All reactions