Created
December 21, 2013 17:06
-
-
Save mason-stewart/8072095 to your computer and use it in GitHub Desktop.
Typed functions in Sweet.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let function = macro { | |
rule { | |
$fn ($($arg ":"$type) (,) ...) $body | |
} => { | |
function $fn ($($arg) ...) { | |
if ($(typeof($arg) == $type &&) ...) {} | |
$($type) (,)... | |
} | |
} | |
} | |
function coolGuy (a :string, b :number) { | |
return 'ya turkey' | |
} | |
coolGuy(1, []); // should fail | |
coolGuy('yay', 4); // should pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment