Multi-Stage JavaScript
Anthony Savidis, Yannis Apostolidis, Yannis Lilis

TL;DR
This paper introduces multi-stage programming extensions to JavaScript, enabling generative metaprogramming with macros evaluated before interpretation, implemented in Spider Monkey for development-time code generation and debugging.
Contribution
It extends JavaScript with staging annotations, implementing a multi-stage macro system in Spider Monkey with minimal core modifications and a debugger for AST inspection.
Findings
Extended Spider Monkey with staging annotations and macro support
Generated pure JavaScript code suitable for browser execution
Developed a debugger for AST visualization and stage inspection
Abstract
Multi-stage languages support generative metaprogramming via macros evaluated in a process preceding the actual interpretation or compilation of the program in which they are used. Macros update the source of their hosting program by emitting code that takes their place in the file, while their code may also be produced, fully or partially, by nested macros. All macros at the same nesting belong to the same stage, with the outer stage collecting the macros affect-ing only the main program. We extended JavaScript with staging annotations and implemented them in Spider Monkey, emitting pure JavaScript code as the final outcome of stage computation. We discuss how the original Spider Monkey system is minimally affected with extensions in the syntax, parser and internal AST structures, and the addition of an unparser, a staging loop, some library functions and a debugger backend component…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsParallel Computing and Optimization Techniques · Software Testing and Debugging Techniques · Software Engineering Research
