From: Etan R. <de...@un...> - 2011-04-13 02:48:01
|
I think renaming to "super" is a pointless idea. Either you know what type the parent is, in which case typing its name instead of super isn't a big deal; or you don't, in which case you can't use super anyway since you can't know what to cast it to. It also doesn't tell you anything useful, since the immediate super relationship isn't particularly helpful whereas the type of the member actually is (especially if you are simply passing it to another function which expects a certain type). Consider: WScreen *scr=current_screen(); mplex_switch_next(&(scr->mplex)); versus WScreen *scr=current_screen(); mplex_switch_next(&(scr->super)); Which one tells you immediately that you've gotten the argument type to mplex_switch_next right and which one leaves you having to remember and or guess? Also consider your given example. In what way is > 'rw->scr.super.super.win=None;' superior to > 'rw->scr.mplex.win.win=None;' ? The super version reads less well (to me), gives me less information, and at that point I would really want a cast (or cast macro) or something to hide it (you probably want that in either case really). What is the current inconsistency exactly? I think there are actually valid reasons to use both the specific cast and the &(obj->mem) indirection. To my mind the cast is more appropriate for assignment to local variables for continued use (it says "I know this X is a Y and I intend to use it as such from now on") whereas the member indirection is useful for examples like the above (it says "I have an X, which I know is a Y, and you need just that bit of it"). I'm not certain we need both, mind you. I'd be fine standardizing on the cast (I wouldn't standardize the other way though). I'd also be fine adding typecast macros (the way glib does), like what ebik said (though I'm not sure we can reasonably get runtime tests the way glib sometimes does). -Etan |