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

rename createOne to new #1872

daurnimator opened this Issue Jan 6, 2019 · 1 comment


None yet
3 participants
Copy link

daurnimator commented Jan 6, 2019

Following 10d2f08#r31841258
It was decided that new would be a better name than createOne.

Furthermore, the standard library still uses .create in many places. They should be changed to .new too.


This comment has been minimized.

Copy link

raulgrell commented Jan 8, 2019

@andrewrk raised a good point in the PR discussion. Shouldn't this mean destroy should be renamed to delete?

I prefer create/destroy to new/delete because to me the latter suggests calling an initializer and a destructor like in C++. In Zig I usually end up calling them init and deinit. Semantically, create and destroy seem more accurate.

EDIT: Actually, my preference was kinda knee-jerk and mostly due to my own personal 'inner semantics'. I have no idea if it matches other developer's expectations. After more thought, 'new' giving you empty memory isn't actually too different to the new operator vs constructors in C++ and Javascript, and even __new__ vs __init__ in Python.

@andrewrk andrewrk added this to the 0.4.0 milestone Jan 8, 2019

@andrewrk andrewrk added the proposal label Feb 3, 2019

@andrewrk andrewrk modified the milestones: 0.4.0, 1.0.0 Feb 3, 2019

andrewrk added a commit that referenced this issue Feb 3, 2019

`std.mem.Allocator.create` replaced with better API
`std.mem.Allocator.createOne` is renamed to `std.mem.Allocator.create`.

The problem with the previous API is that even after copy elision,
the initalization value passed as a parameter would always be a copy.
With the new API, once copy elision is done, initialization
functions can directly initialize allocated memory in place.

 * #1872
 * #1873
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.