xtype (halted)

Check-in [a12db62772]
Login

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

Overview
Comment:Support more Lua binary operators.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a12db627726f756ae19432b57ff6f927bb6df5c76de215eeb7a688b97adc1d53
User & Date: imagic 2021-11-10 19:37:21.000
Context
2021-11-10
19:54
Add rockspec. ... (check-in: 0fddfde383 user: imagic tags: trunk)
19:37
Support more Lua binary operators. ... (check-in: a12db62772 user: imagic tags: trunk)
19:31
Improve tests and add global test. ... (check-in: 786267d6c7 user: imagic tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to README.adoc.
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

-- Create a multifunction.
xtype.multifunction()

-- Global multifunctions namespace for binary operators.
-- For interoperability between third-party types.
-- map of Lua binary op name => multifunction
-- (add, sub, mul, div, mod, pow, concat, eq, lt, le)
xtype.op

-- Low-level API.

-- The type's xtype_stack field is a list of types ordered from the terminal
-- type to the least specific inherited types.








|







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

-- Create a multifunction.
xtype.multifunction()

-- Global multifunctions namespace for binary operators.
-- For interoperability between third-party types.
-- map of Lua binary op name => multifunction
-- (add, sub, mul, div, mod, pow, concat, eq, lt, le, idiv, band, bor, bxor, shl, shr)
xtype.op

-- Low-level API.

-- The type's xtype_stack field is a list of types ordered from the terminal
-- type to the least specific inherited types.

Changes to src/xtype.lua.
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464






465
466
467
function xtype.tplsub(tpl, args)
  return string.gsub(tpl, "%$([%w_]+)", args)
end

-- Global multifunctions namespace for binary operators.
-- For interoperability between third-party types.
-- map of Lua binary op name => multifunction
-- (add, sub, mul, div, mod, pow, concat, eq, lt, le)
xtype.op = {
  add = xtype.multifunction(),
  sub = xtype.multifunction(),
  mul = xtype.multifunction(),
  div = xtype.multifunction(),
  mod = xtype.multifunction(),
  pow = xtype.multifunction(),
  concat = xtype.multifunction(),
  eq = xtype.multifunction(),
  lt = xtype.multifunction(),
  le = xtype.multifunction()






}

return xtype







|










|
>
>
>
>
>
>



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
function xtype.tplsub(tpl, args)
  return string.gsub(tpl, "%$([%w_]+)", args)
end

-- Global multifunctions namespace for binary operators.
-- For interoperability between third-party types.
-- map of Lua binary op name => multifunction
-- (add, sub, mul, div, mod, pow, concat, eq, lt, le, idiv, band, bor, bxor, shl, shr)
xtype.op = {
  add = xtype.multifunction(),
  sub = xtype.multifunction(),
  mul = xtype.multifunction(),
  div = xtype.multifunction(),
  mod = xtype.multifunction(),
  pow = xtype.multifunction(),
  concat = xtype.multifunction(),
  eq = xtype.multifunction(),
  lt = xtype.multifunction(),
  le = xtype.multifunction(),
  idiv = xtype.multifunction(),
  band = xtype.multifunction(),
  bor = xtype.multifunction(),
  bxor = xtype.multifunction(),
  shl = xtype.multifunction(),
  shr = xtype.multifunction()
}

return xtype