On Mon, 2012-04-16 at 04:11 +0800, Chiheng Xu wrote:
> On Sat, Apr 14, 2012 at 11:47 AM, Chiheng Xu <chiheng...@gmail.com> wrote:
> >
> > And I want to say that tree/gimple/rtl are compiler's data(or state),
> > not compiler's text(or logic), the most important thing about them is
> > how to access their fields.
> >
> 
> Given the above assumption, now I doubt the necessity of accessor
> macros or C++ getter/setter method.

According to my experience, it doesn't take more time/effort to write
"tree->code ()" instead of "tree->code" and such getter functions allow
for easier refactoring etc.  If you omit the getters/setters you can't
express things such as immutable objects (well you still could with
const ivars but...), and you'll always have to have the ivar...

> 
> Is "tree->code" more direct and efficient than "TREE_CODE(tree)" or
> "tree->get_code()" ?

What do you mean by efficient?  All of them will (most likely) end up as
the same machine code.  But still, there's a reason why there's a
TREE_CODE getter which is supposed to be used instead of writing
"tree->base.code" everywhere...

Cheers,
Oleg

Reply via email to