Re: Readability question.
Francisco Olarte <[email protected]> Fri, 5 Jun 2026 16:11:54 +0200
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <CA+bJJbxAtVGFtJ+DMYRtpDayf3hqm0f2B00nT2t2dj6OBEhv3A@mail.gmail.com> |
Hello Scott... On Fri, 5 Jun 2026 at 14:05, 'Scott Morgan' via lua-l <[email protected]> wrote: > On 05/06/2026 07:37, Francisco Olarte wrote: > > (a and b and combine(a,b)) or a or b > I think the combine call is a bit of blocker. Not knowing exactly what > it does, even if it's clear with a bit of though (and checking the code). Well , I said: "combine is a function which "merges" tables, or something like add/mul/gcd,", looked clear to me. Anyway, after a little thought and experimentation, and some look at bytecodes ( mainly 4 fun, it's not going to matter a lot ), I have opted for a multi if approach: local function guard(f, a, b) return function(a,b) if a == nil then return b end if b == nil then return a end return f(a,b) end end With more explicit nilness testing, and a return preserving tail-call. Francisco Olarte. -- You received this message because you are subscribed to the Google Groups "lua-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/lua-l/CA%2BbJJbxAtVGFtJ%2BDMYRtpDayf3hqm0f2B00nT2t2dj6OBEhv3A%40mail.gmail.com.