apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject enum and defines naming
Date Sat, 22 May 2004 01:02:36 GMT
Before apr 1.0 is cast in stone any chance public enums and defines will get 
sensible names?

e.g. take a look at:

typedef enum {
     APR_NOFILE = 0,     /**< no file type determined */
     APR_REG,            /**< a regular file */
     APR_DIR,            /**< a directory */
     APR_CHR,            /**< a character device */
     APR_BLK,            /**< a block device */
     APR_PIPE,           /**< a FIFO / pipe */
     APR_LNK,            /**< a symbolic link */
     APR_SOCK,           /**< a [unix domain] socket */
     APR_UNKFILE = 127   /**< a file of some other unknown type */
} apr_filetype_e;

It all looks nice in the declaration but in the code, one needs to scratch the 
head to figure out what APR_REG means. Why not have /^APR_FILETYPE_/ prefix? 
APR_FILETYPE_REG requires no head scratching when reading the code and won't 
collide with some other enum with a totally different functionality.

Same goes for defines, for example:

#define APR_UREAD       0x0400 /**< Read by user */
#define APR_UWRITE      0x0200 /**< Write by user */
#define APR_UEXECUTE    0x0100 /**< Execute by user */

#define APR_GREAD       0x0040 /**< Read by group */
#define APR_GWRITE      0x0020 /**< Write by group */
#define APR_GEXECUTE    0x0010 /**< Execute by group */

#define APR_WREAD       0x0004 /**< Read by others */
#define APR_WWRITE      0x0002 /**< Write by others */
#define APR_WEXECUTE    0x0001 /**< Execute by others */

There are all related to files, why pollute the namespace with such short 
names and not fix them to have a sensible prefix similar to above suggestion? 
/^APR_FILETYPE_/ as in APR_FILETYPE_UREAD.

Further down in the same file we find:

#define APR_FINFO_LINK   0x00000001 /**< Stat the link not the file itself if 
it is a link */
#define APR_FINFO_MTIME  0x00000010 /**< Modification Time */
#define APR_FINFO_CTIME  0x00000020 /**< Creation Time */
#define APR_FINFO_ATIME  0x00000040 /**< Access Time */
...

which looks great!

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Mime
View raw message