-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Evaluate yield expressions in macros #2924
Comments
One minor consistency issue left here is that it's a bit unobvious on the call side, that |
But since |
Nothing, the argument is that the call side looks just like a regular method call with a block, so the semantics within the block changing might surprise one. |
To be honest, I implemented that "feature" of yielding parameters into the macro call very quickly and dirty(-ly?) and I can see it's half-backed, as you for example can't do anything with those yielded expressions other than paste them with About your last comment, other languages use a different syntax for macro calls, for example in Rust names have a bang at the end. Maybe that's a problem in Crystal because there's no distinction between regular calls and macro calls... this makes things more similar to Ruby, and maybe it's better this way because the user doesn't have to worry about this. The problem with yielding things into a macro call is that one has to know it's a macro, and use the macro language inside it, for example paste the expression with |
I just wanted to bring it up in case I was missing an obvious neat solution to it. I don't think it's much of an actual issue, at worst it adds another edit/compile cycle into the workflow because the compiler tells you this was actually a macro call, implicitly. We already have that issue with for example the |
This currently doesn't work:
The error is:
One would expect
b
to be evaluated to"foo"
, and have that be yielded to the block.The yield expression is currently not evaluated because it's used here:
because we want to embed
LibCrystalMain.__crystal_main(argc, argv)
inside the resulting program.The correct way to do this last thing would be to do:
that is, pass a MacroID to the block. And then
yield
should evaluate its expressions as expected.The text was updated successfully, but these errors were encountered: