Created
April 7, 2011 20:26
-
-
Save NilsHaldenwang/908638 to your computer and use it in GitHub Desktop.
Still does not work,...
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
| > mirahc macro_test.mirah | |
| Parsing... | |
| macro_test.mirah | |
| Inferring types... | |
| Inference Error: | |
| macro_test.mirah:23: Cannot find instance method name_set(java.lang.String) on MacroTest | |
| m.name = "Nils" | |
| ^^^^^^^^^^ |
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
| class MacroTest | |
| macro def attr_reader(attr) | |
| quote { | |
| def `attr` | |
| @`attr` | |
| end | |
| } | |
| end | |
| macro def attr_writer(attr) | |
| quote { | |
| def `"#{attr}_set"`(val:String) | |
| @`attr` = val | |
| end | |
| } | |
| end | |
| attr_reader :name | |
| attr_writer :name | |
| def self.main(args:String[]):void | |
| m = MacroTest.new | |
| m.name = "Nils" | |
| puts "My name is #{m.name}." | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment