Allow using Unique with interfaces#4764
Conversation
|
The docs needs updating. They should mention interfaces |
std/typecons.d
Outdated
| transfer can be explicit, by calling $(D release), or implicit, when | ||
| returning Unique from a function. The resource can be a polymorphic | ||
| class object, in which case Unique behaves polymorphically too. | ||
| class object or instance of an interface, in which case Unique behaves polymorphically too. |
There was a problem hiding this comment.
shouldn't it read "or an instance"
There was a problem hiding this comment.
I think the "polymorphic" here applies to both "class object" and "instance of an interface", so it's okay.
|
I was just about to merge this than I saw https://github.com/dlang/phobos/pull/4764/files#diff-4e008aedb3026d4a84f58323e53bf017R220 (Line 220) I think that is a better way to test the dtor call. |
|
Ping @tmccombs |
| { | ||
| /** Represents a reference to $(D T). Resolves to $(D T*) if $(D T) is a value type. */ | ||
| static if (is(T:Object)) | ||
| static if (is(T == class) || is(T == interface)) |
There was a problem hiding this comment.
Does this work with extern(C++) or extern(Windows) classes & interfaces? If not we should not allow them.
There was a problem hiding this comment.
@ZombineDev Good luck detecting them. This is something that @bbasile has been working on.
There was a problem hiding this comment.
I don't know about extern(Windows) - isn't that similar to extern(C) which wouldn't work with classes (I really haven't done much with Windows and D, and Windows linking is way more complicated in general than *nix)? However, as for something like extern(C++) or COM interfaces, wouldn't checking
is(T : Object) && (is(T == class) || is(T == interface))
do the trick?
There was a problem hiding this comment.
That is, if the idea is to exclude them anyway.
There was a problem hiding this comment.
@jmdavis the problem is that Object is a class, so if T is an interface it won't extend Object.
There was a problem hiding this comment.
I don't know a lot about extern(c++) or extern(Windows), but from reading http://dlang.org/spec/interfaceToC.html, it seems like extern(Windows) isn't really relevant since it is more about function calling conventions, and from http://dlang.org/spec/cpp_interface.html it seems like this might work with C++ classes. Although it isn't really clear if it is safe to call destroy on a C++ class. Of course, Unique certainly won't clean up the memory for a C++ class, but that is true regardless of if RefT is T or T*
There was a problem hiding this comment.
IMO this shouldn't be stalled on whether it works with extern(C++)/extern(Windows) classes & interfaces. If they didn't work before then this PR doesn't change the status quo.
wilzbach
left a comment
There was a problem hiding this comment.
IMO this shouldn't be stalled on whether it works with extern(C++)/extern(Windows) classes & interfaces. If they didn't work before then this PR doesn't change the status quo.
I agree!
| assert(!ub2.isEmpty); | ||
| } | ||
|
|
||
| @system unittest |
There was a problem hiding this comment.
FWIW: @JackStouffer has been working on getting rid of these superfluous debug statements
There was a problem hiding this comment.
Good. I was going to request that they be removed but it's easy to submit a PR removing them all at once so I didn't bother.
There was a problem hiding this comment.
Yep, it seems it was common style in this module
I restarted it - hopefully everything should be auto-merged soon :) |
For future reference, how does one do that? |
The Jenkins auto-tester now supports login via GitHub, but it's in testing stage at the moment: |
|
another case of an ancient pull with more than github allows # of status updates, so won't ever report as successful, but it is. I'm going to hit the merge anyway button. |
Thanks for looking out! Btw do you have any ideas on preventing this? Seems like admin overwride is the only option when a PR has been built X times? |
|
A couple thoughts, none of which work really well. Basically count the number of status update sent and after some threshold (maybe 900?):
The real answer is that letting pull requests sit around long enough to accumulate that many updates is the problem, not that there's a limit. |
No description provided.