-
-
Notifications
You must be signed in to change notification settings - Fork 747
std.container.slist: Fix -dip1000 compilable issues #6387
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
Conversation
|
Thanks for your pull request and interest in making D better, @carblue! 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 + phobos#6387" |
| { | ||
| auto newNode = new Node(null, item); | ||
| static if (isSomeString!T) | ||
| auto newNode = new Node(null, item.dup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we agree that this is bad because we duplicate memory without the user explicitly agreeing too.
Why not version(DIP1000) else out the test for now? And/or report the DMD error I reduced here: #6295 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, wouldn't special-casing strings this way break all other reference types anyway?
| { | ||
| auto newNode = new Node(null, item); | ||
| static if (isSomeString!T) | ||
| auto newNode = new Node(null, item.dup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, wouldn't special-casing strings this way break all other reference types anyway?
| Complexity: $(BIGOH m), where $(D m) is the length of $(D stuff) | ||
| */ | ||
| size_t insertFront(Stuff)(Stuff stuff) | ||
| size_t insertFront(Stuff)(scope Stuff stuff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inserting an element in a container is really escaping it, so this function can't accept scope arguments by design, unless it always stores a copy of them.
A new attempt since #6295
https://github.com/dlang/phobos/blob/master/dip1000.mak with
aa[std.container.slist]=-dip1000
Errors when running: make -f posix.mak std/container/slist.test
...
Changing to:
size_t insertFront(Stuff)(scope Stuff stuff)
if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T))
compiles everything except: auto sl = SList!string(["a", "b", "d"]);
Thus I'm going to try with a dedicated constructor (or ?) for the string types, probably including dup-ing consructor arguments. We'll see.