automake-patches
[Top][All Lists]
Advanced

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

Re: FYI: better diagnostics on `+=' misuses (HEAD)


From: Alexandre Duret-Lutz
Subject: Re: FYI: better diagnostics on `+=' misuses (HEAD)
Date: 20 May 2002 22:40:48 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Hi Raja!

Thanks for looking into this.

>>> "Raja" == Raja R Harinath <address@hidden> writes:

 Raja> Hi,
 Raja> Alexandre Duret-Lutz <address@hidden> writes:
 Raja> [snip]
 >> +# $BOOLEAN
 >> +# &conditional_implies_one_of ($COND, @CONDS)
 >> +# -------------------------------------------

 Raja> Is 'conditional_implies_any' a better name?  The function
 Raja> actually computes "implies at least one of".

I renamed it, thanks.

 >> +# @MISSING_CONDS
 >> +# variable_not_always_defined_in_cond ($VAR, $COND)
 >> +# ---------------------------------------------

 Raja> That's an awkward name.  

I'm not good at finding names, even in French.  I though this
one would read nice when used in an `if'.

 Raja> Also what about:

 Raja> if COND1
 Raja> A = foo
 Raja> if COND2
 Raja> D = bar
 Raja> else
 Raja> D = baz
 Raja> endif
 Raja> endif

 Raja> Does it ever occur that you'll need to look at:

 Raja> variable_not_always_defined_in_cond ('A', 'COND1_TRUE COND2_TRUE');

Yes, of course.  For instance this occurs in

if COND1
  A = foo
if COND2
  A += bar
endif
endif

However I can't see any problem with this.  

I'm adding this to the `pluseq9.test' test case to be on the safe side.

 Raja> Given the loop at the end of 'variable_conditions_sub', it may be
 Raja> possible.

Sorry, I'm lost.  I couldn't find this function.

 Raja> I think it would be better to have:

 Raja> variable_subconditions (var, cond)

 Raja> For the above example

 Raja> variable_subconditions ('A', 'COND1_TRUE') 
 Raja>    => ('TRUE') 
 Raja> variable_subconditions ('D', 'COND1_TRUE')
 Raja>    => ('COND2_TRUE', 'COND2_FALSE')

 Raja> I think you can invert the result of this function and prepend
 Raja> COND1_TRUE to get the result of your function.

Yes, I believe this would work too.

I tend to think the current process is more elegant
because we work at a high-level, on sets of conditions:

 1. get the set of all conditions where the variable is defined
 2. invert it (getting the conditions where the variable is not defined)
 3. intersect with the conditions implied at the point of `+='.

Now it's obvious that you have computed the set of conditions on
which `+=' should apply, but for which the variable is not
defined.

We don't even have to know how a condition is defined.


I'm checking in the following.

2002-05-20  Alexandre Duret-Lutz  <address@hidden>

        * automake.in (conditional_implies_one_of): Rename as ...
        (conditional_implies_any): ... this.
        * tests/pluseq9.test: Exercise another case with the new
        `C' variable.
        Suggested by Raja R Harinath.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1298
diff -u -r1.1298 automake.in
--- automake.in 16 May 2002 20:36:31 -0000      1.1298
+++ automake.in 20 May 2002 18:04:07 -0000
@@ -5391,10 +5391,10 @@
 
 
 # $BOOLEAN
-# &conditional_implies_one_of ($COND, @CONDS)
-# -------------------------------------------
-# Returns true iff $COND implies one of the conditions in @CONDS.
-sub conditional_implies_one_of ($@)
+# &conditional_implies_any ($COND, @CONDS)
+# ----------------------------------------
+# Returns true iff $COND implies any of the conditions in @CONDS.
+sub conditional_implies_any ($@)
 {
     my ($cond, @conds) = @_;
 
@@ -6271,7 +6271,7 @@
     foreach my $perm (@perm)
     {
        push @notconds, $perm
-           if ! conditional_implies_one_of ($perm, @conds);
+           if ! conditional_implies_any ($perm, @conds);
     }
     return @notconds;
 }
Index: tests/pluseq9.test
===================================================================
RCS file: /cvs/automake/automake/tests/pluseq9.test,v
retrieving revision 1.1
diff -u -r1.1 pluseq9.test
--- tests/pluseq9.test  16 May 2002 20:36:36 -0000      1.1
+++ tests/pluseq9.test  20 May 2002 18:04:08 -0000
@@ -12,9 +12,11 @@
 
 cat > Makefile.am << 'END'
 if COND1
+  C = c
 if COND2
     A = a
     B = aa
+    C += cc
 else
     A = b
     B = bb

-- 
Alexandre Duret-Lutz




reply via email to

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