Skip to content

[FIX] Fix declarations of cpp2_new #129

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

Merged
merged 2 commits into from
Dec 6, 2022
Merged

Conversation

gerlero
Copy link
Contributor

@gerlero gerlero commented Nov 22, 2022

Small fixes in the declarations of the cpp2_new functions:

  • Take the argument packs by forwarding reference so that the arguments are actually forwarded
  • Remove the ... Args template parameter that is not used

@hsutter hsutter self-assigned this Dec 5, 2022
@hsutter
Copy link
Owner

hsutter commented Dec 5, 2022

Ah, good catch! That totally was a silly error on my part as I was modifying the code, and got into a not-fully-updated-but-happened-to-be-compilable state (sigh).

But I'm glad the core mistake here wouldn't have been possible in Cpp2: In Cpp2 it isn't possible to try to forward a parameter that isn't declared as forwardable, you have to correctly declare forward parameters and then the forwarding is automatic.

Aside: I'm looking forward to when I can start self-hosting parts of cppfront in the coming months, meaning not only writing some of the compiler's own code in Cpp2, but also parts of cpp2util.h. That is, I aim to write that code first as a cpp2util.h2 mixed Cpp1/Cpp2 file with some parts like these three cpp2_new functions written in Cpp2, then generating cpp2util.h from that. That will get rid of some latent bugs like this and make some of the code simpler.

@hsutter hsutter merged commit 510489b into hsutter:main Dec 6, 2022
@gerlero
Copy link
Contributor Author

gerlero commented Dec 6, 2022

But I'm glad the core mistake here wouldn't have been possible in Cpp2: In Cpp2 it isn't possible to try to forward a parameter that isn't declared as forwardable, you have to correctly declare forward parameters and then the forwarding is automatic.

That was my exact thought as I saw it. Hopefully we can start to forget about the whole "perfect forwarder" idiom soon enough.

Aside: I'm looking forward to when I can start self-hosting parts of cppfront in the coming months, meaning not only writing some of the compiler's own code in Cpp2, but also parts of cpp2util.h. That is, I aim to write that code first as a cpp2util.h2 mixed Cpp1/Cpp2 file with some parts like these three cpp2_new functions written in Cpp2, then generating cpp2util.h from that. That will get rid of some latent bugs like this and make some of the code simpler.

Looking forward to that (as well as eventual support for classes, etc.)

Thanks for making this available! I really like your ideas for C++'s future, and I hope this project succeeds.

Azmah-Bad pushed a commit to Azmah-Bad/cppfront that referenced this pull request Feb 24, 2023
[FIX] Fix declarations of cpp2_new
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.

2 participants