|
On 11/10/2010 8:04 PM, steve donovan wrote:
On Wed, Nov 10, 2010 at 1:52 PM, KHMan wrote:If quoting and non-quoting are both valid and have different behaviours, then it is a format fail.Absolutely; I apologize for confusing the issue. A variant on Luz' proposal is very readable: { one = 1, two = 2, three = cond(3,THREE_ALLOWED), four = 4 } where cond is simply function cond(val,condn) if condn then return val end end
Sorry, I wasn't paying real close attention to the actual source codes :-)
Still, I can't help but feel there is something fundamentally wanting from the intentions of this configuration format.
It's similar to the intricacies of the huge number of C #if #defines et al. needed to adapt to multi-platform differences. If this is the case, a complex 'expression' in a kind of Lua style may not be so readable after all.
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.
Not sure how best to solve the problem of adapting configurations to a multitude of slightly different conditions. Has C managed to solve it? It kinda depends really on how much of this kind of complexity a user will force into a configuration script -- two or three levels of something awkward would make one barf...
-- Cheers, Kein-Hong Man (esq.) Kuala Lumpur, Malaysia