JuliaServices / AutoHashEquals.jl

A Julia macro to add == and hash() to composite types.
Other
58 stars 12 forks source link

Allow combination with other macros #19

Closed NHDaly closed 1 year ago

NHDaly commented 3 years ago

This is a super useful macro, but it's a shame it can't be used in conjunction with other struct-level macros, like Base.@kwdef.

This PR is an attempt to make that work :)


I first considered searching the un-expanded input expression for any :struct definition(s), but I think that's suboptimal, since in theory the inner macro may make some changes, and we should support those changes. So instead, this macro first expands the potential inner macro, and then searches the result to find the Base.@doc expression, which should be decorating the new struct definition, and uses that to do its processing.

I think this should work correctly, but probably could do with a bit more error checking to handle the case where the inner macro produces multiple structs with Base.@doc, or doesn't use @doc, etc.

Still, I figured it's better to push up my WIP than to just leave it to rot in private on my computer :)

gafter commented 1 year ago

This PR is out of date. The underlying issue is reported at https://github.com/JuliaServices/AutoHashEquals.jl/issues/33