lua-users home
lua-l archive

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


Hi,

Rici Lake wrote:
> I also find the "delete on nil" behaviour convenient, because it makes 
> it convenient to check the resulting string for lexical errors.

I always used 'return ""' to delete the match. Maybe this is just
conservative programming. Or maybe I just didn't bother to read
the manual to find out that any non-string/non-number would have
worked, too.

> It would certainly make sense to flag inappropriate results as errors.

Yes, definitely. This would've prevented this incompatibility.

> Continuing on the theme of functions, I wonder if it would make sense 
> (and be more consistent) if the replacement table could be a table of 
> functions, and not just of strings; that is, if the table value is a 
> function, then that is the function which is called. I realize that 
> this could be done with a function in the first place, but then so 
> could the table substitution.

Now that you mention it ... when writing the patch I thought that
I could just recycle the initial switch statement for selecting
what to do with the function result or table value. Sort of a
recursive definition with strings or nil as terminals. This
allows tables of functions or functions returning tables or
functions returning functions and so on ...

But I thought this was too radical to get the patch accepted. :-)

[This needs a few changes to keep the stack level unchanged for
the luaL_Buffer methods. And a returned string needs to be
processed literally and not with %n escapes. Oh well ...]

Bye,
     Mike