Skip to content
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

Simplify skipping syntax nodes... #40

Open
gafter opened this issue Mar 28, 2023 · 4 comments
Open

Simplify skipping syntax nodes... #40

gafter opened this issue Mar 28, 2023 · 4 comments

Comments

@gafter
Copy link
Member

gafter commented Mar 28, 2023

in JuliaServices/AutoHashEqualsCached.jl#1 (comment) @nystrom wrote:

I'd make this more robust and just skip LineNumberNode, expecting a struct (or wrapped struct) at the beginning of the block. Or you could apply the macro to all structs in the block.

@NHDaly
Copy link
Member

NHDaly commented Apr 11, 2023

I think i agree with @nystrom. Or at least, you could consider asserting that there's only a single struct declaration in there. It seems it would a bit strange to encounter something like:

@auto_hash_equals begin
    struct Foo end
    struct Bar end
end

As a reader, i would probably incorrectly assume the macro is applying to all the structs, not just the first. No reason to keep this potential misunderstanding, i think.

@gafter
Copy link
Member Author

gafter commented Apr 11, 2023

The problem is that the block might be the result of applying a macro to the struct, and there might be a LineNumberNode in there when it is the result of applying the other macro. This is a scenario I'm trying to enable. So I think I do need to skip LineNumberNodes. However, your suggestion to assert a single struct or apply to every struct in the block if that situation arises - makes sense.

@gafter
Copy link
Member Author

gafter commented Apr 11, 2023

@NHDaly Asserting that there is only one struct would break this package's ability to interoperate with another hypothetical macro that produces a utility type during its expansion (inside begin ... end, which you get implicitly from quote). Is that what we intend?

@gafter gafter transferred this issue from JuliaServices/AutoHashEqualsCached.jl Aug 18, 2023
@NHDaly
Copy link
Member

NHDaly commented Oct 25, 2023

hrmm yeah those are good points! Sorry for my long delay. 🤔 Yeah i don't have a great suggestion here then...

It's worth noting that i think macros run outside-in, so you should be able to see what the user wrote before any macros are expanded inside the usage?

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

No branches or pull requests

2 participants