Open liufengyun opened 7 years ago
Note that https://github.com/liufengyun/gestalt/pull/81 provides a solution to the 2nd problem above, both for syntatic macros and semantic macros.
It seems there's no simple way to do better for the 1st and 3rd problem, especially for syntactic macros.
During semester project presentation, @sjrd mentioned the current approach to hygiene will cause inconvenience:
def macro: Unit = {
q"""
val x = 4
println(x)
"""
}
The code above will not type check, unless gestalt.options.unsafe
is imported, which is a little unfortunate.
Hygiene is a common problem in macros.
We've some initial design ideas about hygiene here:
https://github.com/liufengyun/gestalt/pull/77#pullrequestreview-38177513
Generally, hygiene becomes a problem when a name either in user-program or meta-program changes its originally intended meaning. There are mainly three cases: