On 2008-04-25, Ted Zlatanov <[EMAIL PROTECTED]> wrote:
> It's not a lot of work to support such a language because Lisp itself is
> almost trivial to parse and there's a million embeddable Lisp parsers
> out there.

I didn't mean Lisp support (*yuck*). I meant merely the way ELisp
code defines commands available to the user, so that emacs is able
to query the parameters etc., documentation is included in the
definition, and stuff. An implementation of The (defun ... interactive) 
stuff in Lua, basically.

defcmd("WRegion",       -- Context
       "Execute",       -- Command name
       {ProgramName},   -- List of parameter classes
       "Run a program", -- Documentation
       -- And finally the code
       function(_, _sub, name)
                ioncore.exec_on(_, name)
       end)

bind("WMPlex", "F3", "Execute")
bind("WMPlex", "F2", "Execute", "xterm")

defcmd might also provide the command as a lua function somewhere,
e.g. cmds.WRegion.Execute or maybe WRegion.cmd_Execute. Note that
this works with spaces too, as WFrame["cmd_Switch next"]. This
way perhaps some of the C-side exports could be removed, making
the API smaller. This function would require the _ and _sub arguments
to be passed to it. Basically what 'bind' would then do is pass this
function to the C-side stuff that only understands Lua functions.

Something like that, with ProgramName being some class that defines 
a completor for queries. (Maybe also WRegion, WMPlex should be passed
as class definitions instead of strings... but that's just minor 
details.) Better design suggestions are welcome, and implementations
in particular.

> TV>   * Maybe, especially in conjunction of the previous feature, the 
> TV>     config could be more tree-form, storable in arbitrary structural
> TV>     files (incl. a single Lua table). 
>
> Just use JSON, every major language these days can parse it.  It's far
> from perfect, but compared to XML and others it's a joy to use.  

It's shit, because it doesn't have identifiers and probably was
UTF-8 monoculturist too, IIRC. In Lua, 

        { foo = "bar" }

is equivalent to

        { ["foo"] = "bar" },

the former being special identifier syntax. JSON only provides
the equivalent of the latter.

In case someone took me wrong, I have absolutely no plans of 
abandoning Lua. Quite on the contrary, I will try to use more
Lua and less C in any code I might get around to writing for
Ion4. Lua can be used for table-form config just fine; there's
no need to come up with a new format for storage. (If I did use
something other than Lua, it would be .INI or something *binary*).
But a config addressable in table-form by e.g. external tools, 
offers various possibilities that a pure scripting language
config doesn't.

-- 
Tuomo

Reply via email to