Created
October 11, 2015 17:31
-
-
Save H2CO3/8d8001b30d72d74e6300 to your computer and use it in GitHub Desktop.
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
// takes no arguments, and returns a StringLiteral AST node containing the current date formatted as a string | |
macro CompilationDateAsString() -> std::ASTNode * { | |
// imagine that we already have date/time support in our standard library | |
let cur_date = new std::Date(); | |
return std::StringLiteralAST(cur_date.to_string()); | |
} | |
// So, the following main() function: | |
fn main() { | |
print(@CompilationDateAsString()); | |
} | |
// will be expanded to this: | |
fn main() { | |
print("11/10/2015"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment