3 ms·
I have mixed feelings. For a return value, retval et al are completely appropriate. Same for count. Tmp/temp borrow meaning from whatever they are a temporary f
by dwc 10y ago
I have mixed feelings. For a return value, retval et al are completely appropriate. Same for count. Tmp/temp borrow meaning from whatever they are a temporary for. These are all fine.
But "value" is horrible. You really don't know what it is? You might as well name it "variable". "Str" is in the same boat, unless it's short for "tmpstr".
- mixmastamyk 10y agoValue isn't my favorite, but it says to me that it is data, and not a control variable.
- Grue3 10y ago>You really don't know what it is? What if I don't? Some of us program more abstract things than the others. For example I might want to write a function, that given a tree, and, well, a value, returns a tree where all nodes that have this value are removed. Doesn't matter that the tree in question will in practice be a tree of Flooblooators, I'd rather write reusable code that works for everything.
- dwc 10y agoOk, for those cases I have to agree with you. :)
- bshimmin 10y agoIf I'm iterating over a hash, it seems natural to use "k" and "v" or "key" and "value". Do other people use different names for these?
- dragonwriter 10y agoYeah, there's lots of places where "value" is a well-accepted, clear, domain-specific language for a specific component of a construct, and thus using "value" is an excellent variable name. (Similarly with data: lots of times, I've seen specs where a composite structure had a part called "data". Whether or not that is good naming in the spec, if I'm implementing the spec, using "data" for the element in the program corresponding to that part of the composite in the spec is clearly the exactly right thing to do.)
- bobwaycott 10y agoI typically keep it consistent, using either k,v or key,val (I like the symmetry of var letter length in a weird OCD kind of way).