-
-
Save Yardanico/b6fee43f6da8a3bbf0fe048063357115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
macro unpack*(args: varargs[untyped]): typed = | |
result = newStmtList() | |
let arr = args[0] | |
var i = 0 | |
for arg in args.children: | |
if i == 0: inc i; continue | |
result.add quote do: | |
let `arg` = `arr`[`i` - 1] | |
inc i | |
let data = [1, 2, 3, 4, 5] | |
data.unpack(a, b, c, d, e) | |
echo a, b, c, d, e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment