tech-userlevel archive

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

Re: Improvement for bmake: boolean values



 >> 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.

> In case anyone feels like paying attention to my reactions: I don't
> like this design; it feels too special-cased.  I'd much prefer adding
> some kind of function definition syntax so that bsd.$WHATEVER.mk can
> define yesno() itself.  As a strawman,

> .function yesno(s) ((s ==i "yes") || (s == "1") || \
>       ((s !=i "no") && (s != "0") && error("invalid yesno() argument"))

> (I don't know whether ==i / !=i exist at present, though I think those
> spellings of them don't; I mean case-insensitive == / !=.)

It whould be very nice see something similar to .function from your
example in bmake but I don't beleive it will appear in nearest future.

1) .function is much harder to implement than yesno/istrue/whatever in C
2) if/when .function is implemented, yesno written in C can easily be
   replaced with code from your example, implemneted in, for example,
   bmake_builtins.mk which is always read on bmake startup.
3) Stable API, widely used yesno/istrue function, is more important than
   implementation details.

-- 
Best regards, Aleksey Cheusov.


Home | Main Index | Thread Index | Old Index