Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 23 Jul 2002 12:25:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 23 Jul 2002 12:25:16 -0400 Received: from neon-gw-l3.transmeta.com ([63.209.4.196]:14092 "EHLO neon-gw.transmeta.com") by vger.kernel.org with ESMTP id ; Tue, 23 Jul 2002 12:25:15 -0400 Date: Tue, 23 Jul 2002 09:29:27 -0700 (PDT) From: Linus Torvalds To: Neil Brown cc: linux-kernel@vger.kernel.org Subject: Re: PATCH: type safe(r) list_entry repacement: generic_out_cast In-Reply-To: <15677.15834.295020.89244@notabene.cse.unsw.edu.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1734 Lines: 41 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/