Moreover, if you use the same list in the LHS and RHS, you might have 
surprise in the outcome given the classes

For instance

vars:
    any::
        "list" slist => {"0"};

    Class1::
        "list" slist => {"1", "2"};

    Class2::
        "list" slist => {"3", "4"};

classes:
    Class1 expression => "Class2";

    Class2 expression => fileexists("$(sys.workdir)/bin/cfagent");



What would you expect as outcome ??
You'll want probably 0, 3, 4, 1, 2, but maybe it'll be 0, 1, 2, 3, 4 
(and that's a simple example with no negated classes, where the expected 
outcoume could be debated for hours)

The langage is meant to express the converging behavior of cfengine, and 
if it doesn't you won't be able to use it.

Nicolas

Daniel V Klein wrote:
> I hear that you would prefer to write it one way, but sorry, you can't.  Well,
> you sort of can, you need to look at "policy => free" or the synonym for this
> which is "policy => overridable", but we think you'd be wrong.
>
> Let me give you a counterexample.  I program in C, and there really have been
> times where I wish I could have written
>
>       x = ++y++;
>
> But I can't, so I have to write:
>
>       x = ++y;
>       y++;
>
> I survived.  You can do things the way that they are meant to be done in the
> language, or you can try to find ways around it.  You will probably find a
> way, but then you'll have other problems down the road.
>
> I really recommend that you use the language the way it is intended :-)
>
> -Dan
>
>   
>> --===============1372037647==
>> Content-Type: multipart/signed; boundary="=-=-=";
>>      micalg=pgp-sha512; protocol="application/pgp-signature"
>>
>> --=-=-=
>> Content-Type: text/plain; charset=utf-8
>> Content-Transfer-Encoding: quoted-printable
>>
>> Mark Burgess <mark.burg...@iu.hio.no> writes:
>>
>>     
>>> I think Daniel makes a good case, although Seva is right that defining a =
>>>       
>> new variable is
>>     
>>> less ambiguous, as you would probably not want to rely on the actual cont=
>>>       
>> ents of a
>>     
>>> variable that is changing dynamically in a complex environment.
>>>       
>> The first use case I see is, from my mail on 26th may:
>>
>> =3D=3D=3D=3D
>> body common control
>> {
>>     bundlesequence =3D> { "test" };
>>     version =3D> "0.0.1";
>> }
>>
>> bundle agent test
>> {
>> vars:
>>     any::
>>         "list" slist =3D> {"0", @(l1), @(l2)};
>>
>>     Class1::
>>         "l1" slist =3D> {"1", "2"};
>>
>>     Class2::
>>         "l2" slist =3D> {"3", "4"};
>>
>> commands:
>>     "/bin/echo $(list)";
>> }
>> =3D=3D=3D=3D
>>
>> In this case, l1 and l2 are "technical" lists, lists only used to
>> overcome the lack of append.
>>
>> I really prefer to write:
>> =3D=3D=3D=3D
>> vars:
>>     any::
>>         "list" slist =3D> {"0"};
>>
>>     Class1::
>>         "list" slist =3D> {"1", "2"};
>>
>>     Class2::
>>         "list" slist =3D> {"3", "4"};
>> =3D=3D=3D=3D
>>
>> This feature could be used to build a list by combining items of other list=
>> s:
>>
>> =3D=3D=3D=3D
>> body common control
>> {
>>     bundlesequence =3D> { "test" };
>>     version =3D> "0.0.2";
>> }
>>
>> bundle agent test
>> {
>>
>> vars:
>>
>>     any::
>>
>>         "dirs" slist =3D> {"dir1", "dir2"};
>>      "files" slist =3D> {"f1", "f2"};
>>
>>         "list" slist =3D> {"$(dirs)/$(files)"};
>>
>> commands:
>>
>>     "/bin/echo $(list)";
>> }
>> =3D=3D=3D=3D
>>
>> Results in:
>>
>> =3D=3D=3D=3D
>> /usr/sbin/cf-agent -K=20
>>  !! Redefinition of variable "list" (embedded list in RHS) in context "test"
>>  !! Redefinition of variable "list" (embedded list in RHS) in context "test"
>>  !! Redefinition of variable "list" (embedded list in RHS) in context "test"
>> Q: ".../bin/echo $(dir": $(dirs)/$(files)
>> I: Last 1 QUOTEed lines were generated by promiser "/bin/echo $(dirs)/$(fil=
>> es)"
>> I: Made in version '0.0.2' of '/home/dad/.cfagent/inputs/promises.cf' near =
>> line 21
>> =3D=3D=3D=3D
>>
>> Regards.
>> =2D-=20
>> Daniel Dehennin
>> R=C3=A9cup=C3=A9rer ma clef GPG:
>> gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
>>
>> --=-=-=
>> Content-Type: application/pgp-signature
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v2.0.14 (GNU/Linux)
>>
>> iEYEAREKAAYFAkwKpCQACgkQb97L6l6P4Ft0eQCdHE3ouGNDt0qpaZMhXdEl13Bg
>> WBYAmgNKM2IKXSQyeLrNkn6kp/iu0ugZ
>> =gB+k
>> -----END PGP SIGNATURE-----
>> --=-=-=--
>>
>> --===============1372037647==
>> Content-Type: text/plain; charset="us-ascii"
>> MIME-Version: 1.0
>> Content-Transfer-Encoding: 7bit
>> Content-Disposition: inline
>>
>> _______________________________________________
>> Help-cfengine mailing list
>> Help-cfengine@cfengine.org
>> https://cfengine.org/mailman/listinfo/help-cfengine
>>
>> --===============1372037647==--
>>     
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>   

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to