code generator
leafo opened this issue · comments
add to-lua compiler for type checkers for improved performance. Because performance is highest priority, optimize out error messages since they currently generate a lot of work when going down invalid paths.
Possible interface:
types.string\compile!
-> plain old lua function that performs the transformation
Exploration
It probably makes sense to manually write out optimized version of code for different composite types to understand how things should be structured. We probably have to support fallback for when types can't be compiled, they can be turne d
-- types.string
local value, state = ...
if type(value) == "string" then
return true, state
end
return nil
-- types.string + types.nil
local value, state = ...
if type(value) == "string" then
return true, state
end
if value == nil then
return true
end
return nil
Other ideas
- Have JIT compiling for type checkers that are hot