Hi all,
not sure the title is clear enough, but I was struggling to find a clear description. Although I think what I am trying to do is pretty straight forward and the problem is that I simply don’t understand how macros work.
Situation it’s as follows: I have a lot of boilerplate code to load a dictionary that then gets transformed into a struct. Currently, I have to write a function that checks if the key is present, and then performs some operations.
function set_continue_to(data::OrderedDict)
if haskey(data, :continue_to)
# do Stuff
end
end
Could I do something like this?
@set continue_to begin
# do Stuff
end
set_continue_to(data)
I guess here the problem would be that when defining the macro, data
won’t be available. Also, I don’t know how to generate the function name set_$property
with the macro.
Any guidance/simpler approaches would be appreciated.