[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: ConditionalSet.pm
From: |
Alexandre Duret-Lutz |
Subject: |
Re: FYI: ConditionalSet.pm |
Date: |
Thu, 14 Nov 2002 23:36:52 +0100 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/20.7 (i386-debian-linux-gnu) |
Hi Raja,
Thank you for proofreading me.
[...]
Raja> This is "normalizing" the ConditionalSet in this special case. Won't
Raja> this cause loss of information? Say:
Raja> foo = 1
Raja> if SOMECOND
Raja> foo = 2
Raja> endif
Raja> Then variable_conditions('foo') should be ("TRUE", "SOMECOND_TRUE"),
Raja> not ("TRUE"), I think.
I'm not too concerned by this because it shouldn't occur in
practice. This double declaration of `foo' is disallowed
presently.
However I see no reason for this "normalization". Maybe I thought
it would help in true(). (I wrote new() one month ago, and true()
today...) Let's remove it.
Maybe we should allow this foo/foo construction in the future,
but in this case I think we should adjust the first foo's
condition when the second declaration is encountered. So
variable_conditions('foo') would return ("SOMECOND_FALSE",
"SOMECOND_TRUE").
That day it will probably be a good idea to have a mechanism to
ensure that a set of conditions do not overlap.
[...]
>> + push (@ret, $c->merge_conds ($neg)) if $neg ne 'FALSE';
Raja> ^^^^^^^^^^^^^^^^^^
Raja> If you don't let $cond be 'TRUE', this shouldn't be necessary.
I'll make a separate patch for this, as I'm not entirely sure I
understood what you meant.
[...]
Here is what I'm installing.
2002-11-14 Alexandre Duret-Lutz <address@hidden>
* automake.in (variable_defined): Thinko.
* lib/Automake/ConditionalSet.pm (true): Simplify.
(permutations): Fix documentation.
(new): Don't simplify conditional sets that contain TRUE.
Reported by Raja R Harinath.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1387
diff -u -r1.1387 automake.in
--- automake.in 14 Nov 2002 16:33:15 -0000 1.1387
+++ automake.in 14 Nov 2002 22:09:19 -0000
@@ -6531,7 +6531,7 @@
if (exists $targets{$var}
&& (! defined $cond || exists $targets{$var}{$cond}))
{
- for my $tcond ($cond || ! target_conditions ($var)->false)
+ for my $tcond ($cond || target_conditions ($var)->conds)
{
prog_error ("\$targets{$var}{$tcond} exists but "
. "\$target_owner doesn't")
Index: lib/Automake/ConditionalSet.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/ConditionalSet.pm,v
retrieving revision 1.1
diff -u -r1.1 ConditionalSet.pm
--- lib/Automake/ConditionalSet.pm 14 Nov 2002 16:12:00 -0000 1.1
+++ lib/Automake/ConditionalSet.pm 14 Nov 2002 22:09:20 -0000
@@ -99,8 +99,7 @@
As explained previously, the reference (object) returned is unique
with respect to C<@conds>. For this purpose, duplicate elements are
-ignored, and C<@conds> is rewriten as C<("TRUE")> if it contains
-C<"TRUE">.
+ignored.
=cut
@@ -128,12 +127,6 @@
# ConditionalSet as false for this reason.
next if $cond->false;
- # If we see true, then the whole set is true!
- if ($cond->true && $#conds > 0)
- {
- return new Automake::ConditionalSet $cond;
- }
-
# Store conditions as keys AND as values, because blessed
# objects are converted to string when used as keys (so
# at least we still have the value when we need to call
@@ -218,10 +211,7 @@
sub true ($ )
{
my ($self) = @_;
- # To know whether a ConditionalSet covers all
- # we invert it. invert() will set $self->{'true'}.
- $self->invert unless exists $self->{'true'};
- return $self->{'true'};
+ return $self->invert->false;
}
=item C<$str = $set-E<gt>string>
@@ -292,14 +282,14 @@
Calling $<$set-E<gt>permutations> will return the following Conditional set.
new Automake::ConditionalSet
- (new Automake::Conditional ("COND1_TRUE", "COND2_TRUE", "COND2_TRUE"),
- new Automake::Conditional ("COND1_FALSE","COND2_TRUE", "COND2_TRUE"),
- new Automake::Conditional ("COND1_TRUE", "COND2_FALSE","COND2_TRUE"),
- new Automake::Conditional ("COND1_FALSE","COND2_FALSE","COND2_TRUE"),
- new Automake::Conditional ("COND1_TRUE", "COND2_TRUE", "COND2_FALSE"),
- new Automake::Conditional ("COND1_FALSE","COND2_TRUE", "COND2_FALSE"),
- new Automake::Conditional ("COND1_TRUE", "COND2_FALSE","COND2_FALSE"),
- new Automake::Conditional ("COND1_FALSE","COND2_FALSE","COND2_FALSE"));
+ (new Automake::Conditional ("COND1_TRUE", "COND2_TRUE", "COND3_TRUE"),
+ new Automake::Conditional ("COND1_FALSE","COND2_TRUE", "COND3_TRUE"),
+ new Automake::Conditional ("COND1_TRUE", "COND2_FALSE","COND3_TRUE"),
+ new Automake::Conditional ("COND1_FALSE","COND2_FALSE","COND3_TRUE"),
+ new Automake::Conditional ("COND1_TRUE", "COND2_TRUE", "COND3_FALSE"),
+ new Automake::Conditional ("COND1_FALSE","COND2_TRUE", "COND3_FALSE"),
+ new Automake::Conditional ("COND1_TRUE", "COND2_FALSE","COND3_FALSE"),
+ new Automake::Conditional ("COND1_FALSE","COND2_FALSE","COND3_FALSE"));
=cut
@@ -372,11 +362,6 @@
# It's tempting to also set $res->{'invert'} to $self, but that
# isn't a bad idea as $self hasn't been normalized in any way.
# (Different inputs can produce the same inverted set.)
-
- # If $res is false, then $self covers all cases. The true()
- # method relies on this function to figure that.
- $self->{'true'} = $res->false;
-
return $res;
}
--
Alexandre Duret-Lutz