Messages in this thread | | | Date | Tue, 23 Jul 2002 09:29:27 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: PATCH: type safe(r) list_entry repacement: generic_out_cast |
| |
Hmm, I don't disagree, but "out_cast" reads like "outcast" to me, which has a totally different meaning than the one you want to imply.
I'd rather call it "container_struct()" or something like that, which at least to me sounds more natural.
The difference is that in "out_cast()" you try to describe the operation you're doing. Which is to me not very important or interesting (never mind the confusion with a real word meaning something totally different).
In contrast, "container_struct()" tries to describe what the _result_ is, not how we got there. And I think that's the much more important part, especially when reading the code. You don't care how you get the result, but you do care abotu what the result actually _means_.
And no, I'm not married to the "container_struct()" name. But any name we come up with should have that kind of flavor to it, I feel. I think you can more easily explain something like
#define to_pci_dev(n) \ container_struct(struct device, n, struct pci_dev, dev)
by telling somebody "the 'struct device' is contained within the 'struct pci_dev', and 'to_pci_dev' converts from 'struct device' to the container". You can explain it at a _conceptual_ level without having to worry about what the implementation is. And that kind of conceptual notion is always good.
While in contrast, to explain "out_cast()" you're already starting off at a low-level compiler implementation level.
Maybe "member_to_container()" would be even better?
Linus
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |