lua-users home
lua-l archive

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


>> This is nil because there's no result in the rule. Should I add an
>> assert for this? It'd almost certainly be an error, like a typo in a
>> variable name.
> Since Lua can't distinguish {1} and {1, nil}, that leads to the
> question of what a nil return value means.  Currently, it is allowed
> and means capture nil.
   Right. Lua's lenient handling of nils in tables and multiple
returns makes things tricky. On second thought, it may be better to
just trace a warning about nil results when the debug flag is on.

> Note also this questionable behavior:
>  M {{ {V'_'}, true }} ({}) --> false, ...
>  M {{ {V'_'}, true }} ({nil, [10]=1}) --> true, ...
>  M {{ {V'_'}, true }} ({x=1})) --> true, ...
   That's odd. It should only match where input[1]=something, not
input.x=1. I'll add a few tests and look into it.

> { {{V'x', Star(pat)}, true} }
> would perhaps mean
> { {{V'x'}, true}, {{V'x', pat}, true}, {{V'x', pat, pat}, true}, .....etc.....}
> where one possible value for pat would be V'_', but see above concerns on nil.
   Oh, right, kleene star. I'll think about how to implement that. I
wonder how often it would be used if it were available.

Scott