FieldMetadata.jl icon indicating copy to clipboard operation
FieldMetadata.jl copied to clipboard

[Help wanted, not an issue]

Open briochemc opened this issue 5 years ago • 1 comments

I'd like to add a macro @parameters to my package that uses FieldMetadata as a convenience such that one could call something like

@parameters "MyParams" begin
    a | 1.0u"m/s"
    b | 2.0u"m^2"
end

to be converted to

import FieldMetadata: @units, units
@units struct MyParams{T} <: AbstractParameters{T}
    a::T | 1.0u"m/s"
    b::T | 2.0u"m^2"
end

where AbstractParameters{T} is already defined in my package. I would like a macro like this because although AbstractParameters{T} is useful for my package's inner workings, I would prefer not to expose the user to it. And because it would also be nice to not have the user type the import line.

Considering your very nice work on this package I'm hoping this looks like an easy problem to you, and I was hoping you could help me write this up!

briochemc avatar Feb 20 '20 07:02 briochemc

The easiest thing I can think of would be to define @metadata _parameters and have your @parameters macro simply insert the <: AbstractParameters into the struct AST, then add the @_parameters macro before the struct.

rafaqz avatar Apr 03 '20 07:04 rafaqz