Phobos classes member declaration order

Sean Kelly sean at invisibleduck.org
Fri May 13 15:24:37 PDT 2011


On May 13, 2011, at 2:26 PM, Alexander wrote:
> 
>  Could you please tell me, why you put them at the bottom? I just want to understand why declarations at the bottom are better than at the top... especially when it makes search difficult when working with someone else code...

I think it's more useful to know what a class does and how it works than what data it contains.  YMMV.

>  For instance, talking about core.thread, it took me some time to find the type of m_addr (I am digging for some mysterious segfault in Thread.priority), as this member is used quite often, so search, of course, took some time.

grep can be handy in these situations.  A straight search for "m_addr" turns up 34 lines of results, and the declaration is easy to pick out.  If you want less noise, use a regexp to search for the declaration itself, knowing that it's going to be: WS type WS "m_addr;".  This search turns up only the declaration line:

    grep -E '^ *\w+ +m_addr;' thread.d


More information about the Digitalmars-d mailing list