-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking issue for RFC 2361, "Simpler alternative dbg!() macro" #54306
Comments
I am working on this :) |
…apin Implement the dbg!(..) macro Implements the `dbg!(..)` macro due to rust-lang#54306. cc rust-lang/rfcs#2361 r? @alexcrichton
Implement the dbg!(..) macro Implements the `dbg!(..)` macro due to #54306. cc rust-lang/rfcs#2361 r? @alexcrichton
I just tried this out, and something that was unexpected for me was that it I didn't see this mentioned in the RFC anywhere, but it's possible this was brought up before and now falls under "Unbounded bikeshedding". I don't know if it does, but figured it might be worth sharing my experience in the off chance this hadn't been brought up before. edit (2018-09-25): I just re-read the proposal and found the Expectedlet x = 1;
let y = 2;
dbg!(x, y); Currentlet x = 1;
let y = 2;
dbg!(x);
dbg!(y); |
I suppose one alternative to the tuple discontinuity could be to return nothing at all when more than one argument is provided. |
The original RFC, rust-lang/rfcs#2173, considered it and dealt with this by giving you back a tuple; e.g. |
And, to repeat the argument there: if |
@SimonSapin because if you consider I think the consistent thing to do if you want to pass multiple arguments is to consider what the result would be if you removed the prefix dbg! (a) : typeof(a)
(a) : typeof(a)
dbg! (a,) : (typeof(a),) // note the one-tuple type
(a,) : (typeof(a),) // note the one-tuple type
dbg! (a, b) : (typeof(a), typeof(b))
(a, b) : (typeof(a), typeof(b))
dbg! (a, b, c) : (typeof(a), typeof(b), typeof(c))
(a, b, c) : (typeof(a), typeof(b), typeof(c)) This is symmetrical with how the language behaves and so surprises should be fewer. |
Exclamation mark macros invocations with parentheses are very close in syntax to function calls. The single-item tuple trailing comma syntax special case is specific to tuples, it does not apply to function calls: Whatever we do about other cases, I think |
@SimonSapin I inserted the space to make the consistency I'm talking about more clear ;) I think it is useful to think specifically about For example, one starts out with I do think that the behavior I noted above is more consistent than not outputting anything when multiple arguments are passed. Of course, another option is to not accept multiple arguments at all. |
I feel strongly about this. It seems that proposing otherwise was only a reaction to my earlier comment about the discontinuity between the single-arg v.s. multiple args. I’d rather live with that discontinuity than making a trailing comma significant. |
This seems like a very artificial example constructed specifically for this argument. I think it is exceedingly rare that the debugged expression just happens to be a tuple literal. The normal case is that you add |
If you are not tacking on However, writing The only problem arises when you remove the |
It's been two weeks since the last update on this thread, so in order to help keep the discussion progressing I'm making an attempt to summarize the discussion so far. My hope is that by making explicit which points are agreed / disagreed on, we can keep this proposal going. I hope I got everything right here; if I didn't let me know and I'll update this post. I hope this comes in useful. Thanks! SummaryResolved
Unresolved
DiscussionI personally hope that the parts that are agreed on are enough that they can be moved forward with, allowing to focus the remainder of the discussion on the unresolved questions. That would hopefully put the |
@yoshuawuyts Thanks for the summary :)
I think it should be possible to stabilize the macro as-is and then extend it further with multiple arguments, specialization (when that is stable), and other nice things in a backwards compatible way... Are there any concerns that prevent that? |
cc @oli-obk @alexreg As a general question... do we have any thoughts about how you debug during CTFE? It would be nice if there were some mechanism to do so in a |
Probably needs a separate issue, yeah. It's going to require special compiler support to get around the usual const-restrictions on this sort of thing (I/O). |
I agree, let's discuss this in a separate issue. We can get around the const restrictions by making the debug printer an intrinsic |
@oli-obk Aha yes, that crossed my mind, but I wasn't sure if it worked. Good to hear. |
@SimonSapin How do you feel about landing this as-is? We can revisit extensions such as multiple arguments and such later? Would be nice to have this in 1.32. :) |
The unresolved question is what to do about @rfcbot fcp merge |
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
🎉🎈 Woohoo...! 1.32 is gonna be amazing! =P 🎈🎉 |
Stabilization PR filed in #56395. |
After stabilizing, we might want to? keep this issue open for discussion about extensions and as a landing place for users who want to discuss |
…nSapin Stabilize dbg!(...) Per FCP in rust-lang#54306 (which is ~1 day from completion). r? @SimonSapin The PR is fairly isolated so a rollup should probably work.
The final comment period, with a disposition to merge, as per the review above, is now complete. |
…nSapin Stabilize dbg!(...) Per FCP in rust-lang#54306 (which is ~1 day from completion). r? @SimonSapin The PR is fairly isolated so a rollup should probably work.
…nSapin Stabilize dbg!(...) Per FCP in rust-lang#54306 (which is ~1 day from completion). r? @SimonSapin The PR is fairly isolated so a rollup should probably work.
I don't think it should stay open. Once the RFC is implemented and stabilized, this is done. People can use IRLO threads or the RFCs repo if they want to have discussions about things or propose changes. |
…nSapin Stabilize dbg!(...) Per FCP in rust-lang#54306 (which is ~1 day from completion). r? @SimonSapin The PR is fairly isolated so a rollup should probably work.
The stabilization PR was just merged so there's nothing left to do and thus we can close this issue. |
This is a tracking issue for the RFC "Simpler alternative
dbg!()
macro" (rust-lang/rfcs#2361).Steps:
Unresolved questions:
There are none.
The text was updated successfully, but these errors were encountered: