guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bit naming convention


From: Mikael Djurfeldt
Subject: Bit naming convention
Date: Fri, 20 Apr 2001 00:03:31 +0200

2001-04-19  Dirk Herrmann  <address@hidden>

        * unif.h (SCM_ARRAY_CONTIGUOUS, SCM_ARRAY_FLAG_CONTIGUOUS,
        SCM_ARRAY_CONTP):  Renamed SCM_ARRAY_CONTIGUOUS to
        SCM_ARRAY_FLAG_CONTIGUOUS and use it.

        (SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
        Added.

I think we should improve upon this naming convention.  There are
three things about it which I object to:

1. Names in Guile usually has a logical order of components.  There
   are a few exceptions to the rule, but usually we have increasing
   specificity from left to right.  Following this rule makes it
   easier and faster to read code.

   In SCM_ARRAY_FLAG_CONTIGUOUS, FLAG is less specific than ARRAY
   *and* less specific than CONTIGUOUS.  The correct order would be:

   SCM_FLAG_ARRAY_CONTIGUOUS.

2. I think it is confusing that the name of the flag is
   SCM_ARRAY_FLAG_CONTIGUOUS while the operations on it have the
   suffix _ARRAY_CONTIGUOUS_FLAG.  Why a different order here?

3. I think 29 characters in names is too much.  It makes code look
   ugly and makes reading of the code slower.  However, we *do* have
   the conflicting demand of consistency to pay attention to.

Suggestion:

We use prefixes like

  scm_c_   to indicate a function in the API to be called from C code
  scm_sym_ for symbols
  etc

I suggest that we add:

  scm_f_ for flags
  scm_b_ for bit numbers

#define SCM_F_ARRAY_CONTIGUOUS 16  /* just an example */
#define SCM_B_ARRAY_CONTIGUOUS (1 << SCM_ARRAY_CONTIGUOUS)
#define SCM_SET_F_ARRAY_CONTIGUOUS(...) ...

(SET is a standardized exception to the specificity rule.)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]