automake
[Top][All Lists]
Advanced

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

Re: _SHORTNAME in conditional


From: Gavin Smith
Subject: Re: _SHORTNAME in conditional
Date: Wed, 6 Jan 2016 12:15:34 +0000

On 6 January 2016 at 06:01, Thomas Martitz <address@hidden> wrote:
> Am 05.01.2016 um 23:41 schrieb Gavin Smith:
>> On 5 January 2016 at 21:05, Thomas Martitz <address@hidden> wrote:
>>> Automake source code is a myth to me, I wasn't able to find the code that
>>> implements this limitation (only the place where the warning is printed
>>> (variable_value() => $self->check_defined_unconditionally in Variable.pm)
>>
>> There's the following code in the top-level 'automake' script -
>>
>>                  if ($var)
>>                  {
>>                      # FIXME: should use the same Condition as
>>                      # the _SOURCES variable.  But this is really
>>                      # silly overkill -- nobody should have
>>                      # conditional shortnames.
>>                      $dname = $var->variable_value;
>>                  }
>>
>> does that help?
>>
>
> I saw that, but I couldn't make sense of it. What does that mean? I get
> that the developer deemed it overkill but I can't follow that reason.

Whoever wrote that, if they are still around, can speak for
themselves, but I'll try to explain what I remember from my foray into
the Automake source code a couple of years ago.

The Automake conditional construct means that variables don't have to
have a single value:

if COND
VAR=val1
else
VAR=val2
endif

Here VAR has two values.

Each Automake conditional tests only a single condition. They can also
be nested:

if COND1
if COND2
VAR=val
endif
endif

Adding more conditions reduces the number of occasions that the
contained definition is applicable. The definition here is valid if
"COND1" AND "COND2".

A sequence of nested conditionals can be represented by a list of
conditionals: COND1 AND !COND2 AND COND3.

What about no conditionals at all? This is represented by TRUE. TRUE
is appropriate because when you add more conditions to it, it
disappears: TRUE AND CONDITION is equivalent to CONDITION.

This should answer the question of why when you ask for a definition
under the TRUE condition of a conditionally defined variable, it gives
an error: a definition for the TRUE condition would be an
unconditional definition. (I found this point confusing, myself.)

Note also that the word "Condition" as used in the Automake source
code has a narrower meaning than its common sense: it refers to a
conjunction of conditions only (AND), and not OR for the union of two
conditions.

When asking for a variables value, you have to specify the condition.
>From Variable.pm:

Therefore obtaining the value of a variable under a given
condition involves two lookups.  One to look up the variable,
and one to look up the conditional definition:

  my $var = var $name;
  if ($var)
    {
      my $def = $var->def ($cond);
      if ($def)
        {
          return $def->value;
        }
      ...
    }
  ...

What remains, I believe, is how to get the right condition to look up
the value of the *_SHORTNAME value. I assume that mustn't be easy,
otherwise they would have done it.

(In my humble opinion, Automake conditionals muddle the Automake
source code terribly. DisjConjunctions.pm and Conjunctions.pm together
constitute a weird reimplementation of the Boolean algebra that is
present in every programming language. I thought when I was looking at
the code before that it would at least twice as easy to understand the
code if this feature wasn't present.)



reply via email to

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