Skip to content

untyped vaarg with macro #1700

Answered by lerno
LukyGuyLucky asked this question in Q&A
Dec 20, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

That would normally be true, but macro vaargs are special. In a way they are all lazily evaluated. This is why they are following access order. Secondly, for anything not $vaexpr evaluation will only happen one time, then the value is "locked" in the call itself. So the @foo(ping(1), ping(-1), ping(3141), ping(999 + 1));

Makes the macro do the following evaluation:

  1. Evaluate arg 1, since it appears first as a $vaarg (prints ping[-1])
  2. Note that arg2 will be later evaluated as an $vaexpr
  3. Evaluate arg 0, arg 2, arg 3 (prints ping[1], ping[3141] and ping[1000])
  4. Enter macro
  5. Use arg1 (already evaluated)
  6. Evaluate the arg2 expression two times (this prints pint[3141] twice)
  7. Print the values of th…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@LukyGuyLucky
Comment options

Answer selected by LukyGuyLucky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants