[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: small incompatibility
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sun, 23 Oct 2005 14:15:17 -0200
> It seems a bit odd that nil and false would have such radically
> different meanings.
Maybe I was not clear. The idea is to make both nil and false have
exactly the same behavior: does not substitute. If you want to remove
the match, simply use the empty string.
> I also find the "delete on nil" behaviour convenient, because it makes
> it convenient to check the resulting string for lexical errors.
All you have to do is to add "return ''" at the end of your functions
and add "or ''" at the end of result expressions to get back the
function(k, v) args[k] = v; return '' end)
Not that hard...
> 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.
The value for each table entry is already individualized for one
particular string (the key). If that entry is a function, it will be
called always with the same argument. Unless there is some kind of
side-effect, there seems to be no point calling the function.