Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.)

Michael Matz matz@suse.de
Thu Apr 24 16:12:00 GMT 2014


Hi,

On Thu, 24 Apr 2014, David Malcolm wrote:

> Implicit naming
> ===============
> Several people have suggested that the "gimple_" prefix is redundant.

Not generally though (for instance I find it redundant in the 
cast-method names, but _not_ in the global types).

> Andrew MacLeod suggested in:
>   http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01297.html
> that we could simple drop the "gimple_" prefix.  Combining this with the
> pointer approach, for example, gives:
> 
>   -      gimple def, loop_phi, phi, close_phi = stmt;
>   -      tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
>   +      gimple *def;
>   +      phi *loop_phi, *phi, *close_phi = as_a <phi *> (stmt);

That is, I'm not fond of a global type named just "phi" or "bind" or 
"assign".  There the gimple_ prefix is sort of fine, we could perhaps 
trade it for a _t suffix though (phi_t, assign_t?  hmm don't know, still 
feels too broad).  But for method names (that necessarily don't conflict 
with method names from other classes or even just with local variable 
names) such prefixes are useless.

For similar reasons I find the "as_a_" prefix too verbose in method names, 
"as_" is enough to convey the meaning.  OTOH the awkward _a suffix is 
necessary for the globally named templates to not clash with single word 
names of local variable like "as" or "is".  That is, methods simply can be 
named much more sensible and still be shorter than global entities as they 
always carry class context with them.  I'm sorta fond of methods :)


Ciao,
Michael.



More information about the Gcc-patches mailing list