-
Notifications
You must be signed in to change notification settings - Fork 205
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
What does toString
on a record do?
#2389
Comments
Ugh, yeah. Honestly, I think the right thing is to print the fields and all of their names. Give the users what they want to see when they are debugging their app. We keep the shape and names around for printing function types, so it doesn't seem unreasonable to do the same thing for records. But I know some people would really like to be able to tree-shake those names. I sympathize but... it's really painful to make debugging harder. I'm happy to defer to letting the core lib and compiler folks hash this one out. :) |
tl;dr: The specification should not force retaining information that isn't necessary at runtime. Records are structural data, and we can see from the program code how they are destructured. If a compiler can see that a record type contains an element which is never used, it should be able to completely eliminate that element and never store a value. If the I'd at least prefer to keep the We probably will retain enough information to know the named element names of records, in order to facilitate We should then also document, very clearly, on (Which also means that a result of |
Could we:
? |
@mit-mit in principle, yes, and I don't think that's necessarily a bad idea. But it's always somewhat risky to have code that behaves one way when you run your tests and another way when out in the wild. Any code that parses the result of
? |
Can we also specify that it may choose to eliminate field values? |
Oof, maybe? |
* Address a bunch of records issues. - Support constant records. Fix #2337. - Support empty and one-positional-field records. Fix #2386. - Re-add support for positional field getters Fix #2388. - Specify the behavior of `toString()`. Fix #2389. - Disambiguate record types in `on` clauses. Fix #2406. * Clarify the iteration order of fields in `==`. * Copy-edit the sections on const records and canonicalization. There should be no meaningful changes. I just: - Fixed some misspellings. - Used Markdown style consistent with the rest of the doc. - Re-worded things to, I hope, read a little more naturally. - Removed the parenthetical on identical() in a const context because that felt a little too academic. * Leave the order that positional fields are checked in == unspecified. * Clarify that positional fields are not sugar for named fields. Specify the evaluation order of fields.
The record proposal says:
This is all well and good, but we have to implement something. So, what do we do here?
cc @munificent @eernstg @lrhn @jakemac53 @natebosch @stereotype441 @rakudrama @mraleph
The text was updated successfully, but these errors were encountered: