Skip to content

Conversation

@krux02
Copy link
Contributor

@krux02 krux02 commented Jan 24, 2019

My implementation for nim-lang/RFCs#122

Work in progress. There are lots of examples in the implementation (most of the code) that is supposed to show how the mentioned examples would work in the new quoteAst proposal.

There are issues that need to be discussed though.

fixed issues

This is the list of issues that will be fixed when this PR is finished:

#10326
#7375
#9745
#7889
#8220
#7589
#7726
#10430

Preserving line information is verbose

This only affects the generated code. To preserve the line information from the quoted AST in the generated newTree expression, a new function to set the line information has been added to the macros module. This is the difference in the generated code for the same quoted AST.

newTree(NimNodeKind(115), newTree(NimNodeKind(26), ident("echo"), newLit("Hello "),
                                 expectNimNode(newLit("world")), newLit("!")))
newTreeWithLineinfo(NimNodeKind(115), LineInfo(
    filename: "/home/arne/proj/nim/Nim/lib/experimental/quote2.nim", line: 75,
    column: 4), newTreeWithLineinfo(NimNodeKind(26), LineInfo(
    filename: "/home/arne/proj/nim/Nim/lib/experimental/quote2.nim", line: 75,
    column: 9), ident("echo"), newLit("Hello "), expectNimNode(newLit("world")), newLit(
    "!")))

And here the line information is only set for two nodes, It isn't even enabled for literals and identifier. For more complex macros this could increase the memory consumption and required performance dramatically for something that is only needed for debugging (stack traces).

@alehander92
Copy link
Contributor

Why isn't the discussion about the unquoting alternatives (. .) etc in the RFC ? Is the full RFC accepted , or is this just a proof of concept?

@krux02
Copy link
Contributor Author

krux02 commented Jan 24, 2019

You don't know if something works until you try it. The (. and .) pair is just an idea, not something that is implemented.

@alehander92
Copy link
Contributor

Ok, I just meant that the (. thing is interesting(even if i still personally prefer ` without nesting), so it would make sense for people to discuss it

@krux02
Copy link
Contributor Author

krux02 commented Jan 24, 2019

@alehander42 I moved the mentioning of (. to the RFC

@narimiran
Copy link
Member

From what I understand, this was superseded by #11823. (If that's not the case, feel free to reopen this one.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants