[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] APow 1.0
- From: "Soni L." <fakedme@...>
- Date: Thu, 23 Feb 2017 17:53:46 -0300
On 23/02/17 01:46 PM, Soni L. wrote:
On 23/02/17 01:44 PM, Soni L. wrote:
And keep in mind, right-associativity is what lets you chain
annotations in the first place.
On 23/02/17 01:39 PM, Egor Skriptunoff wrote:
On Sun, Feb 19, 2017 at 12:20 AM, Soni L. <email@example.com
local notnil = require "notnil".notnil
local function f(x)
x = notnil ^ x
assert(not pcall(f, nil))
Unfortunately, this is not extendable to chained annotations like
local function f(x, y, z)
notnil ^ x ^ y ^ z
-- do something
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.
Let's say you want a typechecked annotation, using typecheck:
local myann = apow.annotation ^ typecheck.checked ^ function(self,
Not that this particular case is useful (it'll return nil if there's a
type error, but won't return an error message), but you wouldn't be able
to do this with left-associativity.
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.