[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bsdinstaller-discussion
Subject:    another drastic change: make scriptlets like config files
From:       "Chris Pressey" <cpressey () gmail ! com>
Date:       2006-09-04 20:25:34
Message-ID: f32433650609041325x1dd23ec7q6256fd0477809532 () mail ! gmail ! com
[Download RAW message or body]

Now that the previous sweeping change is in, here is the next one I'm
planning to do.  A long while ago we changed the config file format
such that each config file is just a series of variable assignments
(instead of having to construct and return a table.)  A short while
ago I noticed that we could do this to the "scriptlets" that configure
the steps and menu items, too.  The result is a more declarative style
that's IMO easier to comprehend.

Unfortunately this change will touch essentially EVERY line of EVERY
scriptlet because of the indentation change!

Since the indentation is changing anyway, I think I'll re-indent the
scriptlets to use half the indentation that we've been using up til
now - that is, 4-space indents for nested program blocks (function
definitions, if-then, while-do, etc) and 2-space indents for statement
continuations and tables.  The main arguments for it are that 8-space
indents are overkill (especially in Lua,) 8 spaces isn't written in
stone, and that consistency within each file is the most important
factor for readability.  A nice bonus is that user messages (which
appear fairly often in these files) don't have to be split up over as
many lines.

The declarative format should also add some nice touches to
scriptlets.  For example, a scriptlet can declare a function that
returns a boolean that determines whether the scriptlet should be run
or not.  An example (similar to the GEOM stuff:)

condition = function()
    if App.state.storage:get_disk_count() < 2 then
        return false, "setting up a mirror needs at least two disks"
    end
    return true
end

Scriptlets will probably also need to list what modules they use, for example:

uses = { "App", "Disk", "Socket" }

(I'm less sure how that will turn out though.  Just about every script
will need to use "App", at least, so that would get annoying.)

-Chris

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic