-
Notifications
You must be signed in to change notification settings - Fork 49
read(_field)/write(_field): Make incurred implementations overridable
#394
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
Conversation
lib/1.4/dml-builtins.dml
Outdated
|
|
||
| template _reg_read_as_field is (register, read_register, read_field) { | ||
|
|
||
| template read_register_via_read_field is (register, read_register, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
PR Verification: ✅ success |
c4968b7 to
9b786b3
Compare
9b786b3 to
d47f2c0
Compare
…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).
d47f2c0 to
f101db1
Compare
In particular, added documentation to note what the relevant template is to override the
write_register/read_registerimplementations (which are no longer internal).