Skip to content

Instantly share code, notes, and snippets.

@soegaard
Created June 21, 2014 22:31
Show Gist options
  • Save soegaard/4fc5d05f547ae3c38e36 to your computer and use it in GitHub Desktop.
Save soegaard/4fc5d05f547ae3c38e36 to your computer and use it in GitHub Desktop.
Define functions for phase 1
macro compiletimeutils {
case { $ctu ()}
=> { letstx $is_stx = [makeIdent("is_stx", #{$ctu})];
return #{function $is_stx(s) {
return ((typeof s)=="object") &&
!(s[0] == undefined) &&
((typeof(s[0]["token"]))=="object") } ;} }
}
macro m {
case {_}
=> { compiletimeutils();
console.log(is_stx(#{1})); /* prints true */
console.log(is_stx(1)); /* prints false */
console.log(is_stx({})); /* prints false */
return #{void(0)} } }
m;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment