This was working! It's no more the case
module StructMacro
import gololang.macros.CodeBuilder
function pokemon = |typeName, sound| -> toplevel(
structure(): name(typeName: getValue())
: members("name", "owner"),
augmentType(typeName: getValue())
: withFunction(publicFunction()
: name("makeNoise")
: param("this")
: block(
returns(sound)))
: withAugmentation("fightable")
)
module StructTest
import StructMacro
augmentation fightable = {
function fight = |this, other| {
println("## " + this: name() + " fight against " + other: name())
println("> " + this: makeNoise() + "!")
println("> " + other: makeNoise() + "!")
}
}
&pokemon("Pikachu", "pika")
&pokemon("Salameche", "salameche")
function main = |args| {
let pika = Pikachu("Pika", "Sacha")
let charla = Salameche("Charla", "Lise")
pika: fight(charla)
}
golo compile macros.golo && golo golo --files test.golo
## Pika fight against Charla
> pika!
> salameche!