lua-users home
lua-l archive

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

On Wed, Nov 10, 2010 at 08:00, Gopalakrishnan Subramani
<> wrote:
> There could be a lot more complicated cases but basically they relay on the
> device capability.
> In the enumeration, for example, we need to display many items in the combo
> box which needs to be filtered based on device features. As much as we get
> the configuration in the Lua is benefit to us since it is better than XML
> and very clean and small snippet of ugly conditions are OK to manage.
> We are trying to get DSL and create a framework out of Lua with C++/COM and
> .NET binding. All we need to train people on how to use the configuration
> efficiently.
> Regards,
> Gopalakrishnan
> On Wed, Nov 10, 2010 at 7:30 PM, KHMan <> wrote:
>> On 11/10/2010 9:20 PM, steve donovan wrote:
>>> On Wed, Nov 10, 2010 at 2:34 PM, KHMan wrote:
>>>> Maybe a better question would be, what is an example of a worst-case
>>>> complexity version of the original configuration snippet? Working on
>>>> simple
>>>> cases may be misleading.
>>> Yes, maybe 'median' complexity since there are always pathological
>>> cases, as long as there are pathological programmers ;)
>>> At least Lua does not need to drop to a primitive semi-language (like
>>> the C preprocessor) to express conditional evaluation. A mixture of
>>> the imperative and the declarative?
>>> Apparently people like if-statements - but then is it a _configuration_
>>> format?
>> Good point. That's why I'm particularly interested in the bigger picture,
>> rather than one simple configuration snippet.
>> The OP says it's for Industrial Automation Devices. (I think engineers
>> will get by with *anything* -- even if it's really wacky -- since we
>> survived primitive PLC programming... :-))
>> The tendency of the ideas is towards programming snippets in the
>> configuration file. I too wonder how much functionality the file is supposed
>> to embody, and where the boundary is drawn between configuration code and
>> behaviour code. Blurring the line means more effort by users to muddle
>> through the thing. The CompSci part of me wishes for clear code designed for
>> human beings.
>> There is enthusiasm for exploring such a format, but there seems to be too
>> little that we know (so far) to judge the overall merits of doing such a
>> thing.
>> --
>> Cheers,
>> Kein-Hong Man (esq.)
>> Kuala Lumpur, Malaysia

My way to go about this would be:
Config = {}
table.insert(Config, {1, 'one'})
table.insert(Config, {2, 'two'})
if THREE_ENABLED then table.insert(Config, {3, 'three'}) end
table.insert(Config, {4, 'four'})

You might wrap table.insert in another function for added readability,
but already this is a nice concise way to keep related options grouped
together and make it clear to those without much Lua knowledge what's
going on.

Sent from my toaster.