I sometimes want to know the memory layout of a class/struct. Having all the fields together makes that a *lot* easier.
Nick On Fri, Sep 29, 2017 at 5:35 AM, Jason Orendorff <jorendo...@mozilla.com> wrote: > On Thu, Sep 28, 2017 at 2:10 AM, Lars Hansen <lhan...@mozilla.com> wrote: > > > I dislike this proposal. (a) A lot of the code I work with already have > > fields-at-the-beginning as the predominant pattern in the smaller classes > > (jit, wasm) so this would be major churn for no gain. (b) For large > > classes this is an anti-pattern, like having all the vars at the > beginning > > of a function in C; it separates the data from the functions that work on > > that data. (c) It brings private and public parts of the code close > > together, and separates public data from public methods. > > > > Objections (a) and (b) make sense to me, so let's make the rule "For > reasonable-sized classes, put all the fields together, at the top > (immediately after any necessary typedefs). For unreasonably large classes, > do whatever seems best (but let's try to avoid making more of these)." > Better? > > I don't really understand objection (c); maybe an example from SM code > would clear it up. (But let me grant in advance that all style rules are > subordinate to George Orwell's sixth rule: "Break any of these rules sooner > than say anything outright barbarous.") > > -j > _______________________________________________ > dev-tech-js-engine-internals mailing list > dev-tech-js-engine-internals@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals > _______________________________________________ dev-tech-js-engine-internals mailing list dev-tech-js-engine-internals@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals