Make Loc.toChars pure and nothrow#9520
Conversation
|
Thanks for your pull request and interest in making D better, @jacob-carlborg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#9520" |
thewilsonator
left a comment
There was a problem hiding this comment.
Loc is a very important struct w.r.t memory consumed by the compiler.
Since showColumns is only used in that method it would be better to make it a default parameter of toChars().
2a48bfd to
b5b9e99
Compare
|
Walter doesn't like default parameters as far as I know. But I can try to make it a required parameter. |
|
As long as its not taking up more memory than is necessary I really don't care. A required parameter is fine, might make the diff a bit bigger. @WalterBright any preferences? |
b5b9e99 to
1ea68e9
Compare
|
Using a parameter with a default value in |
|
Hiding the use of a global behind a default value is not a good practice, it's faking a good practice. Either make it explicit or not pure. |
|
Been thinking of this for a while, seems like a good step forward. Before
After
This is akin to Haskell's way of carrying monads around, and (less so) Scala's implicits. I think we're in good company. I'm in favor of this idiom. |
|
Yes, thank you Andrei. I tried making it a required parameter but that resulted in too many change so I gave up. I was both tiresome to do all those changes and the resulting diff would have been too large. With this approach it's now possible continue modifying the code base to explicitly pass in the |
|
Another approach would be to instead of printing the error immediately, collect them a print them later. Then the printing function could implement what Lines 161 to 170 in e42f83e Part of #9480. |
No description provided.