From:  Jim Blandy <>
Date:  29 Sep 2017 02:25:54 Hong Kong Time

Re: C++ coding style rule for keeping class fields together


On Thu, Sep 28, 2017 at 1:55 AM, Benjamin Bouvier  wrote:

> Agreed with Lars. In particular regarding (b), I tend to read unknown code
> by starting with the data (the "what") then look at how it's manipulated
> (the "how").

Jason and I are in firm agreement with you about this. We read code the
same way. (This is Fred Brooks' "show me your tables" line Jason quoted.)
This is what the proposal is intended to help.

> This stylistic change would be a huge regression to me, and
> there are already some places where the fields are grouped at the end,
> which I've found these very confusing.

The idea behind Jason's proposal is to put the "what" all together, and the
"how" all together, to make this easier. Why would this be a regression?

That being said, I agree having the fields grouped is much better than the
> messes that are JSContext or JSRuntime, sometimes intertwining fields and
> methods which don't even seem related to the fields defined just before.

I think JSContext and JSRuntime are special cases. In modern style, global
variables are verboten, but what we've replaced them with is Structs Passed
Everywhere. Especially since we removed support for "requests"
(SpiderMonkey's old concurrency model), JSContext and JSRuntime have
evolved from having particular meanings to hold whatever state random bits
of SpiderMonkey need.