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
Ergonomics: Rename various XtoY
functions to YfromX
#6128
Comments
XtoY
functions to YfromX
XtoY
functions to YfromX
I think this synergizes pretty well with #5909 |
Hmm, no discussion in this proposal. I'd like to put an opposite opinion on this. Everything is of course IMO and just some thoughts to provide an alternative vision. We have the following code:
How we read this code:
What method of reading is more common? I don't know. What I know without statistics is that in data transformations the pattern This is what related to naming things. Regarding to your example for me it looks like an attempt to work around an issue with renaming instead of finding some better approach. For example it may be solved by "pipes":
|
@deflock There's a fallacy in your thinking: the implicit assumption that left-to-right is "forward". It is not necessarily, and in fact is explicitly not in some very common places (nested function application). In your example, "forward" is top-to-bottom or bottom-to-top, neither of which implies a lateral direction. So reversing the word order has no effect in that case. Regarding your other points: there are many places in programming where output precedes input at least syntactically, for instance all variable assignment where result location precedes value, and the aforementioned nested function application. Also just because something is "common" isn't a good reason to do it if there are practical arguments to the contrary (see our pointer dereference syntax). And I did propose pipes once; they were rejected. Within the bounds of what we have, renaming the builtins is a perfectly practical solution. |
Consider the following snippet from RV64I codegen:
This is a transformation of
raw
. To know what it does, we read right to left:@enumToInt
, then@intToEnum
, thenreturn
. However, to parse those function names, we read left to right:enum
toint
,int
toenum
. This direction switching is bad for scanning and slows down comprehension.I propose this alternative:
Now, everything can be read in a single pass:
raw
:enum
->int
->enum
->return
.This is applicable in many places.
The text was updated successfully, but these errors were encountered: