Skip to content

Use typed fields in models #98

@goerz

Description

@goerz

@kwdef struct HydrogenAtom
Z = 1
mₑ = 1.0
a₀ = 1.0
Eₕ = 1.0
= 1.0
end

has all fields in the HydrogenAtom types as Any. Even if you don't care about performance, this is not a good idea:

julia> HA = HydrogenAtom(Z="1")
Antique.HydrogenAtom(Z=1, mₑ=1.0, a₀=1.0, Eₕ=1.0, ħ=1.0)

julia> E(HA)
ERROR: MethodError: no method matching -(::String)

My recommendations would be the proof-of-concept implementation

If you want to support both a full ASCII and a Unicode API, then I don't think you can use @kwdef. If you stick to ASCII (which I might, at the end of the day, just because it put so much less demand on contributors of new models), and @kwdef is probably possible.

This applies to all models, obviously, not just HydrogenAtom

Ref. openjournals/joss-reviews#8545 (comment)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestjossIssues related to JOSS reviews

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions