[Top][All Lists]

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

Re: [Cfengine-develop] my own branch of the tree

From: Luke A. Kanies
Subject: Re: [Cfengine-develop] my own branch of the tree
Date: Tue, 20 Jan 2004 11:20:30 -0600 (CST)

On Tue, 20 Jan 2004 address@hidden wrote:

> > I would probably do something that looked a
> > heckuva lot like ruby, rather than perl:
> >
> > control:
> >     list = ( 1 2 3 4 )
> >
> > copy:
> >     ${list}.each { |item|
> >             /path/to/files/${item} dest=/new/path/${item}
> >     }
> >
> > links:
> >     ${list}.each { |item|
> >             /usr/local/bin -> /usr/local/software/${item}/bin/*
> >     }
> >
> > I'm not saying that this is _the_ solution, but once you get used to it,
> > it continues to make sense.
> What would nested iteration look like in this scheme?

        list1 = ( 1 2 3 4 )
        list2 = ( a b c d )

        ${list1}.each { |number|
                ${list2}.each { |letter|
                        /${number} dest=/${letter}

This is pretty much straight out of ruby.  I think this exact syntax would
not work, because variables aren't objects so the concept of calling a
method on a variable (".each") isn't really valid.  I like the basic idea,

> Cfengine does support nested iteration (see so-called 2d lists).
> It is just not allowed on all variables.

I could not find any mention of 2d lists in the cfengine reference, and
none of the mentions of lists seemed to be speaking about them.  Where is
this described?

> It strikes me that one of the biggest problems in iteration is
> what happens when there is nesting and how it should be evaluated.

I think the above system is pretty clear and clean, but it requires a
number of things cfengine doesn't have, with variable scope being near the
top of the list.

> Today, iteration lacks conceptual clarity in cfengine, but it does
> work.

Yeah, I just find that it never works in a way that's useful to me.
AFAIK, it only works in shellcommands and links, with some strange
implicit iteration in other areas (like the 'home' directive).

I might be able to figure out what's happening, but I'm essentially
positive that I could not comfortably hand such iteration off to someone
else.  Either way, though, the available iteration has never satisfied my
needs for abstraction, largely because it needs to be configuration-wide,
not just specific actions.


    "What is the sound of Perl?  Is it not the sound of a wall that
     people have stopped banging their heads against?"
                --Larry Wall in <address@hidden>

reply via email to

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