lua-users home
lua-l archive

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




On 23/02/17 01:44 PM, Soni L. wrote:


On 23/02/17 01:39 PM, Egor Skriptunoff wrote:
On Sun, Feb 19, 2017 at 12:20 AM, Soni L. <fakedme@gmail.com <mailto:fakedme@gmail.com>> wrote:

    local notnil = require "notnil".notnil

    local function f(x)
      x = notnil ^ x
    end

    assert(pcall(f, 1))
    assert(not pcall(f, nil))


Unfortunately, this is not extendable to chained annotations like the following:

local function f(x, y, z)
  notnil ^ x ^ y ^ z
  -- do something
end

due to right-associativity of "annotation operator"

Fortunately, that's a syntax error anyway. And what was it supposed to return? x? y? z? It can't return all 3.

And keep in mind, right-associativity is what lets you chain annotations in the first place.

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.