xtype (halted)

Check-in [4ba6c66a6c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Minor example fix.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4ba6c66a6ce597fc8348f04ef8cb76d94f676b79933016f3a9092cf8a6c42b01
User & Date: imagic 2021-01-26 20:30:37.000
Context
2021-11-08
19:30
Improve API checks. ... (check-in: 37988572a5 user: imagic tags: trunk)
2021-01-26
20:30
Minor example fix. ... (check-in: 4ba6c66a6c user: imagic tags: trunk)
20:22
Implement xtype system. ... (check-in: 43e2a34aa0 user: imagic tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to examples/bench_check.lua.
1
2
3
4
5
6
7
8
9
10

11
12
13
14
-- Benchmark type checking.
package.path = "src/?.lua;"..package.path
local xtype = require("xtype")

local n = ...
n = tonumber(n) or 1e7

local T = xtype.create("T")
local t = setmetatable({}, {xtype = T})


for i=1,n do
  a = xtype.is(T, "xtype") and xtype.is(t, T) and xtype.is(i, "number")
end
assert(a)










>




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- Benchmark type checking.
package.path = "src/?.lua;"..package.path
local xtype = require("xtype")

local n = ...
n = tonumber(n) or 1e7

local T = xtype.create("T")
local t = setmetatable({}, {xtype = T})

local a
for i=1,n do
  a = xtype.is(T, "xtype") and xtype.is(t, T) and xtype.is(i, "number")
end
assert(a)