-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[WIP] evalonce: let a {.evalonce.} = expr
: side-effect safe, avoids copies
#13750
Conversation
Can we see some borrow checking please? It shouldn't be too hard to do, the information a Nim program usually contains implies we're well prepared for it. |
#13739 doesn't need this and should use the compilers ability to determine if its an lvalue or not by itself. |
In my opinion Nim already has too many features. I really don't want to add more features unless proven that we need them. So before new features are added:
This is required to verify if this feature can really address all use cases.
How would it help to write code more correct? How could it simplify code? I really like if you can prove that a specific feature would eleminate a big chunk branches. I did this in my PR here:
Make sure this feature works well with other features of the language. Does it work well with lambdalifting? Does it work well with macros? And last but not least, I don't like the name After all only if proven this feature is required it should be added.
|
Please change the name |
I agree with @krux02 here. If I have code that needs to only evaluate an expression once, I use a variable assignment. If I have code that is hitting a bottleneck because of memory copying, I have the expression return a reference. If I can't do that, I explicitly use a pointer, not some hidden unsafe mechanism. This code isn't memory safe, isn't thoroughly tested, and I'm not convinced it's needed enough to be included in the standard library. It's not even documented as being memory unsafe! Nim shouldn't be C++ - we shouldn't need numerous damned hacks to achieve things that the compiler can figure out, or that can be done with common operations. Why don't we focus on making our existing features better/more thorough/more performant instead. |
@timotheecour How is this different from |
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
var b {.byaddr.} = expr
#13508known limitation that could be lifted in future PR's
this limitation can be lifted in the future either by doing (recursive) code transformation
or by making openArray 1st class