[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: Automake::Conditional
From: |
Akim Demaille |
Subject: |
Re: FYI: Automake::Conditional |
Date: |
08 Oct 2002 09:30:49 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
| I'm checking this in.
| This is one more step towards the goal of defining targets and
| variables as objects.
Yahoo! Congrats! This patch is *beautiful*! I mean it.
| My next step will be to define Automake::ConditionalSet to
| represent disjunctions of conditions we currently represent as a
| list of Automake::Conditional (e.g., the list of conditionals in
| which a variable is defined.)
Great!
| The rationnal for doing this is
| - this degreases automake.in
| - this documents conditionals in a single place
| - with ConditionalSet we'll be able to *cache* the result
| of complex algorithms like invert_conditions
You can add that ultimately, targets and variables will share a lot
more of their code. So we will even be able to add new objects, such
as functions!
Ahem, I'm being told that there are no functions in Make. Too bad :)
| An object is a (blessed) reference,
| which is a scalar, so one might think it can be used as a key...
| Well, that's wrong.
|
| my $cond = new Automake::Conditional "COND1_TRUE", "COND2_FALSE";
| $targets{'rule'}{$cond} = "here:1";
|
| When used as key, $cond will be converted as a string
| (something like "Automake::Conditional=0x12345678"). So when you
| later fetch the keys,
|
| my @conds = keys %{$targets{'rule'}}
|
| you will be returned a list of *strings*, not a list of
| blessed references. Silly language...
Aaaaaaaaaaarg! Puke puke puke!
This is amazing... I wonder what the rationale for this silly
behavior can be.
| Index: lib/Automake/Conditional.pm
| ===================================================================
| RCS file: lib/Automake/Conditional.pm
| diff -N lib/Automake/Conditional.pm
| --- /dev/null 1 Jan 1970 00:00:00 -0000
| +++ lib/Automake/Conditional.pm 7 Oct 2002 09:16:16 -0000
[...]
| +
| + # Likewise, but using a list of atomica conditional strings
atomic I guess.
| +
| + # Catch some common programming errors:
| + # - A conditional passed to new
| + confess "`$cond' is a reference, expected a string" if ref $cond;
| + # - A conditional passed as a string to new
| + confess "`$cond' doesn't look like a condition" if $cond =~ /::/;
``Common programming errors'' :) :) :) How many time did you make it
this weekend?
| +# Undocumented, shouldn't be needed out of this class.
| +sub has ($$)
| +{
| + my ($self, $cond) = @_;
| + if (exists $self->{'hash'}{$cond})
| + {
| + return $self->{'hash'}{$cond};
Is this really what you mean? What if `$self->{'hash'}{$cond}' is
`undef'? Wouldn't returning 1 be safer?
| + }
| + return 0;
| +}
| Index: tests/cond12.test
| ===================================================================
| RCS file: /cvs/automake/automake/tests/cond12.test,v
| retrieving revision 1.3
| diff -u -b -r1.3 cond12.test
| --- tests/cond12.test 8 Sep 2002 13:07:55 -0000 1.3
| +++ tests/cond12.test 7 Oct 2002 09:16:18 -0000
| @@ -32,14 +32,18 @@
| my $failed = 0;
| sub check_reduce($$) {
| my ($inref, $outref) = @_;
| - my @result = sort &Automake::variable_conditions_reduce(@$inref);
| - my $correct = 1;
| - $correct = 0 if (join(",", @result) ne join(",", @$outref));
Wow, I didn't know there were such test in Automake.
Hm... Again, maybe it is a silly idea, but...
Can't we imagine having this modules (.pm) embed their own minitest
suite? And be able to `run' them to exec the test suite?