On Tue Sep 5 17:24:21 2023 +0000, Zebediah Figura wrote:
I'd argue for "vsir_dimension_from_sm4()".
Okay, I renamed the function.
However, I have been told that it is better if function names start
with a verb, but I guess we are not following that rule much in this part of the code base.
That rule is news to me. :) And yeah, most vkd3d and wined3d code
starts function names with the main structure/object the function is operating on. Actually, tangentially, we'll probably want to go with "vsir_dimension" instead of "vkd3d_shader_dimension" as well if we're going to rename it shortly anyway. I think I've said something like this, but that wasn't quite what I was trying to communicate. Usually the point is that I want a function name to communicate that it does something, which usually means it has a verb *in* it. I would probably have been objecting against functions that looked like a noun phrase. And of course, usually starting with the object that it's a "method" of is preferred, so it shouldn't start with a verb per se.
I accidentally posted before I was done, but to expand on this: this is a general guideline, but not a hard and fast one. And there are a couple exceptions that often show up.
As here "X_from_Y" or "X_to_Y" pattern is one; it's not a verb per se but it still describes an action.
The other conventional exception, where we usually *do* name a function after a noun phrase, is generally a simple wrapper for CONTAINING_RECORD. E.g. hlsl_ir_expr(), wined3d_adapter_vk().
But like all things, this is a matter of general guidelines and there are probably other reasonable places where one can give a function a name that doesn't include a verb.