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

strip minor improvement #16444

Merged
merged 6 commits into from
Dec 23, 2020
Merged

strip minor improvement #16444

merged 6 commits into from
Dec 23, 2020

Conversation

ringabout
Copy link
Member

No description provided.

@juancarlospaco
Copy link
Collaborator

{.noinit.} ?.

@timotheecour
Copy link
Member

@juancarlospaco

{.noinit.} ?.

where?

@juancarlospaco
Copy link
Collaborator

juancarlospaco commented Dec 23, 2020

Without {.noinit.} it implicitly injects result = "" , on the proc as procedure pragma (this wont change with danger).
I use it a lot, is safe if your proc assigns to result directly and explicitly, correct me if I am wrong.

And if it does not work, then better we discovered a Bug on the pragma. 🤷

@timotheecour
Copy link
Member

timotheecour commented Dec 23, 2020

Without {.noinit.} it implicitly injects result = "" , on the proc as procedure pragma (this wont change with danger).

I suspected that's what you mean; note that this affects a large percentage of procs and there's no reason to single strip out; IMO there's a better approach than annotating each proc individually, compiler can/should do this automatically when safe to do so. Let's discuss this in another dedicated issue, it's an important one.

links

@juancarlospaco
Copy link
Collaborator

juancarlospaco commented Dec 23, 2020

When return is a concrete primitive type, not auto, and func is single line should be easy to just inject the noinit.
Nim does this even when result is directly assigned a static value.

@ringabout ringabout requested a review from Araq December 23, 2020 10:35
@Araq Araq merged commit 417c250 into nim-lang:devel Dec 23, 2020
mildred pushed a commit to mildred/Nim that referenced this pull request Jan 11, 2021
* strip minor improvement
* add more tests
* Update tests/stdlib/tstrutils.nim

Co-authored-by: Timothee Cour <[email protected]>
ardek66 pushed a commit to ardek66/Nim that referenced this pull request Mar 26, 2021
* strip minor improvement
* add more tests
* Update tests/stdlib/tstrutils.nim

Co-authored-by: Timothee Cour <[email protected]>
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.

4 participants