-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new genAst
as replacement for quote do
#17426
Conversation
77e1f1c
to
49bcd70
Compare
49bcd70
to
9ab92d9
Compare
PTAL |
@Araq anything else needed for this PR? |
Documentation. It's barely comprehensible. Take this example: macro fun(a: bool, b: static bool): untyped =
let c = false # doesn't override parameter `c`
var d = 11 # var => gensym'd
proc localFun(): auto = 12 # proc => inject'd
genAst(a, b, c = true):
# echo d # not captured => gives `var not init`
(a, b, c, localFun())
assert fun(true, false) == (true, false, true, 12) This is not an example how to use You could also write a guest post about this new module, I can imagine lots of design effort went into it avoiding "quote do"s limitations and bugs. |
9ab92d9
to
c8e4a17
Compare
PTAL, I've improved the docs and piggy backed on quote do's own example of simplified unittest.check, but made it better here by showing the lhs+rhs on error. It's intentionally simplified (eg no care taken about multiple evaluation issues or deferred failure, which are out of scope). The resulting code is compact and readable. I also kept the other example but with more explanations
why not, maybe some time after this PR is merged and some initial usage feedback |
8f0f217
to
4dbd234
Compare
4dbd234
to
429a2f4
Compare
Cool! |
continuation of #11722, see previous discussion in that PR.
genAst
subsumesquote do
.refs #11722 (comment)
closes these issues by providing a suitable replacement:
quote do
#7375newLit
, you were getting a crash)genAst
instead ofquote do
quote
)for #7889, see unittests showing this is fixed (for both
quote do
andgenAst
) by using regular call syntax instead of method call syntax; can be therefore closed as dup of #7085future work
genAst
as replacement forquote do
#17426 (comment))quote do
; note thatquote do
can be backported to 1.0 so that code can migrate togenAst
and be forward and backward compatible (it's a pure library solution).