tech-userlevel archive

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

Re: make: new modifyer :Y



On Sun, Nov 06, 2011 at 08:32:50PM +0300, Aleksey Cheusov wrote:
> About year and a half ago I proposed to add to make(1) a function
> that checks a value for "YES" or "NO" case-insensitively and returns 1
> or 0 in order to avoid using ugly constructions like
> !empty(varname:M[Yy][Ee][Ss]) in Makefiles and replace them with
> something shorter and more maintainable.
> 
> http://mail-index.netbsd.org/tech-userlevel/2009/03/25/msg001953.html
> 
> After some discussion it was decided that adding new expression is not
> feasible and David Holland proposed to add :istrue modifier. Later he
> rejected his own idea in favour of general function support in bmake.
> 
> Since then neither function support nor typed values appeared in bmake,
> so, I'd like to raise that question again.  I still want to avoid
> constructions like !empty(varname:M[Yy][Ee][Ss]) or
> ${varname:U:tl} == "yes".
> 
> Taking into account how often we check variables for YES/1/NO/0 values
> I've implemented variable modifier :Y in C. In short, with a help of
> this modifier we can rewrite the code
> 
> 
>   .if !empty(MKXXX:M[Yy][Ee][Ss])
>   .endif
> 
> or
> 
>   .if empty(MKXXX:M[Nn][Oo])
>   .endif
> 
> with a more elegant
> 
>   .if ${MKXXX:Y}
>   .endif
> 
> Find the patch in the attachment. Objections?

Yeah, I'm not a fan of "Y" - it's too terse, and seems to be an obscure
idiom for a longer sequence. I'm not sure what the 'Y' modifier in other
make programs does, but I'm fairly sure it's not this - the NetBSD make(1)
program is used in many places you would not even think of.

If you're looking for brevity of Makefile expression, then I'm all for it.
Unfortunately, the other side of the coin wrt brevity is comprehension,
and I just don't see the merit of this change here.

So for me - please don't do this, it's non-standard, it's more obscure
than the other code, and strikes me as being change for change's sake.

Regards,
Alistair


Home | Main Index | Thread Index | Old Index