Skip to content

Conversation

@schveiguy
Copy link
Member

@schveiguy schveiguy commented Apr 13, 2018

Most of the version(unittest) stuff here is not needed at all (there's no reason to guard unittests with version(unittest)).

A couple of the changes are not trivial, however.

See #6450 for more details.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @schveiguy!

Bugzilla references

Your 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 locally

If 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#6452"

void* m;

@nogc nothrow
size_t addr() { return cast(size_t) m; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this in the unittest, even though the version block had no imports, as I can't imagine there's a good reason for adding addr to the global namespace as a public symbol. The loss of UFCS is mitigated by the fact that we always were calling this on m, so it actually gets shorter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loss of UFCS might make this less intuitive. I know I had to double check what addr does. What is the gain in changing the function signature?

Do the function attributes and the function definition have different indents or is it just the web display?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I didn't change the function (and just made it a static), then it would become addr(m). I changed it to m_addr to make it more obvious what it is.

The attributes were indented differently. This is what my editor did. But I have redone the function into a lambda, which looks quite nice.

Copy link
Contributor

@edi33416 edi33416 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just some nits

// unnecessary import of std.experimental.allocator
import std.experimental.allocator : RCIAllocator, RCISharedAllocator;
static assert(is(RCAllocInterface == RCIAllocator)
|| is (RCAllocInterface == shared RCISharedAllocator));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are at it, you could also remove the shared keyword as this was before declaring RCISharedAllocator as a shared struct.

void* m;

@nogc nothrow
size_t addr() { return cast(size_t) m; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loss of UFCS might make this less intuitive. I know I had to double check what addr does. What is the gain in changing the function signature?

Do the function attributes and the function definition have different indents or is it just the web display?

@schveiguy
Copy link
Member Author

Fixed nits, let me know what you think on the m_addr thing.

@edi33416
Copy link
Contributor

I think this solves the (my 😄 ) "problem" perfectly

@edi33416
Copy link
Contributor

Don't you have to call m_addr or does it get called by the compiler? I can see that the Win32 build is failing because of this

std\experimental\allocator\mallocator.d(402): Error: incompatible types for `(__lambda1) & (15)`: `uint delegate() pure nothrow @nogc @safe` and `int`

@schveiguy
Copy link
Member Author

Hah! the tests passed my mac, forgetting that this was a windows-specific test.

@schveiguy
Copy link
Member Author

I thought there was a way to alias a function lambda so that it becomes a real function? Oh well, will revert back to a function, but we don't need the attributes, they should be inferred.

@schveiguy
Copy link
Member Author

@edi33416 fixed. Not as pretty, but still short. Hopefully it passes this time, I tested something similar on my mac.

@edi33416 edi33416 merged commit 6b72ce3 into dlang:master Apr 13, 2018
@schveiguy schveiguy deleted the version_unittest_p3 branch April 13, 2018 19:25
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.

3 participants