Publication Date

Spring 2015

Degree Type

Master's Project

Degree Name

Master of Science (MS)

Department

Computer Science

First Advisor

Thomas Austin

Second Advisor

Chris Pollett

Third Advisor

Ron Mak

Keywords

Javascript Macro Library Syntax Parameters

Abstract

Lisp and Scheme have demonstrated the power of macros to enable programmers to evolve and craft languages. A macro is a rule or pattern that specifies how a certain input sequence should be mapped to an output sequence according to some defined procedure. Using a macro system a programmer can introduce new syntactic elements to the programming language. Macros found in a program are expanded by a macro expander and allow a programmer to enable code reuse. Mozilla Sweet.JS provides a way for developers to enrich their JavaScript code by adding new syntax to the language through the use of macros. Sweet.JS provides the possibility to define hygienic macros inspired by Scheme.

“In this paper, I present the implementation of a “syntax parameter” feature for the Sweet.JS library. A syntax parameter is a mechanism for rebinding a macro defi- nition within the dynamic context of a macro expansions thereby introducing implicit identifiers in a hygienic fashion. Some time hygienic macro bindings are insufficient such as with “anaphoric conditionals" where the value of the tested expression is avail- able as an it binding. With syntax parameters, instead of introducing the binding unhygienically each time, we instead create one binding for the keyword, which we can then adjust later when we want the keyword to have a different meaning. As no new bindings are introduced hygiene is preserved. "

Share

COinS