-- tests/selectors.cat -- the a.b / a::b selector syntax. -- -- a.b -- read the member `b` of `a` -- a.b(args) -- call member `b` WITH `a` as self -- a::b -- static read (no self) -- a::b(args) -- call `b` WITHOUT self -- -- `a:b` is gone. local counter = { n = 0 } counter.bump = function(self, by) self.n = self.n + by return self.n end counter.bump(3) counter.bump(4) print("with self:", counter.n) -- a plain table field local point = { x = 10, y = 20 } print("field x:", point.x) -- static access: no receiver is passed local util = { twice = function(x) return x * 2 end } print("static:", util::twice(21)) -- method vs static on the same member local obj = { val = "obj" } obj.who = function(self) return "self=" .. self.val end print(obj.who()) -- static form passes no receiver: the first arg is the real first arg local math2 = { add = function(a, b) return a + b end } print("static no self:", math2::add(2, 3))