Skip to content

Conversation

@lwaern-intel
Copy link
Contributor

In particular, added documentation to note what the relevant template is to override the write_register/read_register implementations (which are no longer internal).


template _reg_read_as_field is (register, read_register, read_field) {

template read_register_via_read_field is (register, read_register,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to polish naming convention a bit. It is correct that write_register is instantiated via write_field, but the result of that is that the write_field method is called via the read_register method, i.e. an instance of "via" with reverse direction.

I haven't thought of a better name yet.

Copy link
Contributor Author

@lwaern-intel lwaern-intel Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminating the ambiguity can be done by read_register_impl_via_read_field or read_register_impl_from_read_field. These are long and unwieldy... but at the same time, we don't expect people to use reference these very often, and having the name be documentation on its own has its virtue. I'm leaning towards this (specifically the one using "from"). Your opinion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to map this to standard OO patterns, it looks a bit like Adapter Pattern, but where all three classes are the same. I.e., register needs a read_register, and we have a read_field, so we create an adapter from read_field to read_register.

Would read_field_to_read_register make sense?

Copy link
Contributor Author

@lwaern-intel lwaern-intel Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would read_field_to_read_register make sense?

Probably, but I still find myself preferring read_register_impl_from_read_field, despite its length. Its meaning is less ambiguous, and -- in particular -- it tells exactly the thing that's of interest for anyone who has any reason to reference the template. Besides, even though read_field_to_read_register is shorter, it's still long. How cumbersome a template is to reference doesn't change much when it's 27 chars vs. 34 chars.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason for _to_ would not be length, but rather familiarity: there is some precedence related to the Adapter pattern (e.g. LightningToMicroUsbAdapter in the wikipedia article), whereas I haven't seen ImplFrom used for similar patterns elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed elsewhere, I mixed things up, read_register is not a template name so the _to_ pattern is not applicable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no wait IT DOES EXIST I WAS HORRIBLY WRONG

BUT WHY DOES IT EXIST

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed verbally. the templates currently have no good reason to exist but don't really harm anything and Erik is looking into something that could give them a good reason to exist. So: read_register_from_read_field is the naming scheme.

@syssimics
Copy link
Contributor

PR Verification: ✅ success

@lwaern-intel lwaern-intel force-pushed the lw/utility-flexibility branch 2 times, most recently from c4968b7 to 9b786b3 Compare November 19, 2025 08:19
@lwaern-intel lwaern-intel force-pushed the lw/utility-flexibility branch from 9b786b3 to d47f2c0 Compare November 25, 2025 11:52
…rridable

In particular, added documentation to note what the relevant template is to
override the `write_register`/`read_register` implementations (which are no
longer internal).
@lwaern-intel lwaern-intel force-pushed the lw/utility-flexibility branch from d47f2c0 to f101db1 Compare November 25, 2025 14:11
@lwaern-intel lwaern-intel merged commit 55dc8fb into intel:main Nov 26, 2025
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.

3 participants