bison-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] More %define/%code encapsulation


From: Paolo Bonzini
Subject: Re: [PATCH] More %define/%code encapsulation
Date: Wed, 17 Jan 2007 08:50:45 +0100
User-agent: Thunderbird 1.5.0.9 (Macintosh/20061207)

How about b4_percent_define_if_true instead? Given that we have _ifdef, _if seems like it ought to be like m4_if, which is not about booleans.

Yes. OTOH we also have b4_flag_if. Maybe b4_percent_define_flag_if, but these long macro names are getting more and more annoying to me.

- for _ifval, I'm thinking of

m4_define([b4_class_name], [b4_get_percent_code([package])dnl
b4_get_percent_code_ifval([package], [.])$1])

Why not the following?

  m4_define([b4_class_name], [b4_percent_code_get([[package]])dnl
  m4_ifval(b4_percent_code_get([[package]]), [.])$1])

Well, just because!  But if I want to be nitpicking, these are my reasoning:

- you "save more characters" than you show because it's b4_percent_code_ifval (you have one more _get). If the names were shorter (omitting the _percent, for example...) the savings would be close to 50%!

- one less pair of parentheses.  m4 has already too many.

- quoting the if macros correctly is somewhat counterintuitive.

To be clear, you mean that the no-value %define form:

  %define my_boolean_variable

is equivalent to:

  %define my_boolean_variable "1"

but you want it equivalent to:

  %define my_boolean_variable ""

Using "1" for true is needlessly C-like. In m4 (but also in the C preprocessor) it's common that "ifdef" marks whether a flag if true or false, without looking at the actual value. Since the grammar's source code will not change, and the default is not documented (%define is not documented at all!!!), I find this change valuable.

Also, using a default of "" gives the least-surprise (compare with C) when the no-value form is used with a non-boolean variable.

Paolo





reply via email to

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