Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Use marker types to improve ergonomics of mod fundamental #24

Closed
wants to merge 9 commits into from

Conversation

AngusGMorrison
Copy link
Contributor

@AngusGMorrison AngusGMorrison commented Nov 20, 2023

Working through the nutation models, I now better understand the usage of the various fundamental arguments, and believe we can make a significant improvement to the ergonomics of these arguments than previous C libraries afford.

Problem

Different conventions define the same fundamental arguments differently for the same
bodies, but we lack a coherent way to represent this. For example, the mean longitude of the ascending node of the Moon is defined differently in the IERS2003 and MHB2000 conventions.

The set of traits currently defined and implemented in fundamental.rs is IERS 2003-only, but we don't want to define a new trait for each combination of conventions and argument, which will quickly get out of hand and lead to long, convoluted method names to avoid clashes when implemented on the same body.

Nor do we want to define a new body for each set of conventions – there are enough of them as it is.

Proposed solution

Following a recommendation in Rust for Rustaceans, we can define a marker type for
each convention, make the body generic over the marker, and implement the same trait for each marker.

The body remains zero-sized, its instances are constant, and there's no need to namespace fundamental arguments trait declarations.

This is also clearer for consumers of the Lox API, who no longer have to wonder why mod fundamental provides only IERS 03 fundamental args.

My recommendation, initially at least, is to limit the scope of these changes to mod fundamental – please read the code example from beginning to end 🙏

The provided example is limited to a single file, and isn't intended to reflect any proposed module structure.

@AngusGMorrison
Copy link
Contributor Author

Closing this as no longer needed.

The outcome of discussions on Element is that there is highly unlikely to be any scenario in which we need to refer to any set of bodies having a given fundamental argument generically. Therefore, the existing trait definitions can be removed and replaced with simple method implementations on the bodies directly. These methods can be suffixed with _iers03 or _mhb2000 as required, unifying the calling conventions for these arguments.

@helgee helgee deleted the am/marker-experiment branch March 5, 2024 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant