ct.js: Compile Time Function Execution (CTFE) in JavaScript
Inspired from the CTFE of the D language, ct.js permits to
generate efficient code while maintaining expressiveness.
By G. Lathoud, December 2019 and later. Contact: glat@glat.info
The Boost license apply, as described in the file
Open your Developer Tools & JS console to see the examples in action.
The sources for expl.js
and ct.js
are displayed below. For fun, I used ct.js
to dump and prettify the two source files:
ct( () => {
ct.def( one, (s) =>
`write_source_code(${s}_source_code,"${s}.js")` ).ct;
ct.one("expl").ct;
ct.one("ct").ct;
})();