lua-users home
lua-l archive

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

I wrote in a previous message:
> Then I could just write my own version adaptable local function like:
>    -- Returns math.floor (a / b)
>    --
>    local function idiv (a, b)
>       if math.idiv then
>          return math.idiv (a, b)
>       else
>          return ifloor (a / b)          -- ifloor from above
>       end
>    end

Of course this is better written as:

  local idiv = math.idiv or function(a,b) return ifloor (a / b) end

[In general that's a pattern I tend to like to follow when writing
version-adaptable code using some new function NEW_FUN: define a local
version of NEW_FUN whose value is "NEW_FUN or function (...) ... end".]


Barometer, n. An ingenious instrument which indicates what kind of weather we
are having.