On Mon, Jun 30, 2025 at 09:29:38AM +0200, Peter Zijlstra wrote:
> On Fri, Jun 27, 2025 at 09:36:08AM -0700, Josh Poimboeuf wrote:
> > On Fri, Jun 27, 2025 at 12:29:30PM +0200, Peter Zijlstra wrote:
> > > Naming seems inconsistent, there are:
> > >
> > >   sym_has_sec(), sec_changed() and sec_size()
> > >
> > > which have the object first, but then most new ones are:
> > > 
> > >   is_foo_sym() and is_foo_sec()
> > > 
> > > which have the object last.
> > 
> > For the "is_()" variants, I read them as:
> > 
> >   "is a(n) <adjective> <noun>"
> > 
> > e.g.:
> > 
> >   is_undef_sym(): "is an UNDEF symbol"
> >   is_file_sym():  "is a FILE symbol"
> >   is_string_sec() "is a STRING section"
> > 
> > Nerding out on English for a second, many of those adjectives can be
> > read as noun adjuncts, e.g. "chicken soup", where a noun functions as an
> > adjective.
> > 
> > If we changed those to:
> > 
> >   "is <noun> <adjective>?"
> > 
> > or
> > 
> >   "is <noun> a <noun>?"
> > 
> > then it doesn't always read correctly:
> > 
> >   is_sym_file():   "is symbol a file?"
> >   is_sec_string(): "is section a string?"
> 
> English aside; things like sym_*() create a clear namespace, and
> sym_is_file() can be easily read as sym::is_file().

A namespace isn't necessarily a good thing if it hurts readability.  A
file symbol is not a file.  A string section is not a string.  A rela
section is not a relocation.

It makes the code less readable because the natural English reading
("section is a string") doesn't make logical sense, so it takes longer
for the brain to parse.

-- 
Josh

Reply via email to