tech-userlevel archive

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

Re: Improvement for bmake: boolean values

On Wed, Mar 25, 2009 at 01:57:30PM +0200, Aleksey Cheusov wrote:
> In both 4.4BSD bsd.*.mk files and pkgsrc mk files boolean variables are
> widely used: MKMAN, MKCATPAGES, USE_LIBTOOL and tons of others.
> One traditional way to represent boolean values is to use YES/NO strings
> for representing true/false respectively. Another widely used practice
> is to use 1/0 values.
> In my view YES/NO looks better/easier than 1/0 for human.
> On the other hand 1/0 values make mk code much easier and cleaner.
> Problems:
> 1) there are two incompatible way to represent boolean values.
>    In pkgsrc there is a special secret table (ask tnn@)
>    listing variables and their true/false values
> 2) empty{MKCATPAGES:M[Nn][Oo]} looks very ugly and make the code dirty
> 3) empty{MKCATPAGES:M[Nn][Oo]} is not equivalent to
>    !empty{MKCATPAGES:M[Yy][Ee][Ss]}
>    (other/bad values are treated as either true or false)
> To solve these problems I propose to implement new function for
> bmake, say "yesno", treating 1 and [Yy][Ee][Ss] as logical true,
> and 0 and [Nn][Oo] as logical false.
> Example:
>    MKMAN = yes # or YES|...|NO|No|nO|1|0
>    ...
>    .if yesno(MKMAN)
>        # make man pages here
>    .else
>        # do not make man pages here
>    .end
> In my view this can make mk code cleaner and boolean values in bmake
> much easier to understand and use.
> I think this approach closes the problem once and forever.

Personally I like this idea. :)


Home | Main Index | Thread Index | Old Index