Skip to content

std.string and std.traits: use locally-scoped selective imports and document module-scope symbols#4370

Merged
DmitryOlshansky merged 1 commit intodlang:masterfrom
joakim-noah:imports
Jun 3, 2016
Merged

std.string and std.traits: use locally-scoped selective imports and document module-scope symbols#4370
DmitryOlshansky merged 1 commit intodlang:masterfrom
joakim-noah:imports

Conversation

@joakim-noah
Copy link
Contributor

@joakim-noah joakim-noah commented May 27, 2016

Checked with ddmd, as always, also fixed extra spaces in std.uni, never mind, that's now fixed in a later PR, #4380, so removed it from this one.

import std.meta;// AliasSeq, staticIndexOf
import std.range.primitives;// ElementEncodingType, ElementType, hasLength, hasSlicing, isBidirectionalRange, isForwardRange, isInputRange, isOutputRange, isRandomAccessRange
import std.traits;// isConvertibleToString, isNarrowString, isSomeChar, isSomeString, StringTypeOf, Unqual

Copy link
Contributor

Choose a reason for hiding this comment

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

These need to be formatted differently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As in those lines are too long or what?

Copy link
Contributor

Choose a reason for hiding this comment

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

That, and there's no space between ; and //, and the comments should be aligned if possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do they need to exist at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That, and there's no space between ; and //, and the comments should be aligned if possible.

There's other instances without the space in phobos, but whatever, I'll add it and break up the lines. As for alignment, these aren't really comments, so shouldn't be a need.

Why do they need to exist at all?

The plan is to remove the comment slashes and turn these into selective imports, once we have the green light for module-scope selective imports in phobos, after the current transitional period to accomodate downstream users is over.

Copy link
Contributor

Choose a reason for hiding this comment

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

So if I understand correctly, these imports only exist to trigger the deprecation messages?

Copy link
Contributor Author

@joakim-noah joakim-noah May 30, 2016

Choose a reason for hiding this comment

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

So if I understand correctly, these imports only exist to trigger the deprecation messages?

I don't think they'll trigger anything right now, but not sure. Martin asked that we don't make any module-scope imports selective till the transitional period is over, so I'm just listing the imported symbols for now.

Update: I believe the issue is that some users may use the transitional import flags to revert to the previous leaky selective imports in dmd, so if these phobos imports were turned into selective imports now, these symbols would then leak into other modules for those users. We're giving them time to clean up all downstream code that inadvertently relies on such leaks, after which the old behavior will be removed and we can make these selective.

@DmitryOlshansky
Copy link
Member

Traits are OK, std.string I'm skeptical of.

@burner
Copy link
Member

burner commented Jun 2, 2016

as @DmitryOlshansky ;-) split this PR into two, get the traits part merged and work on string. It's makes every bodies life easier if PR's are as focused as possible.

@joakim-noah
Copy link
Contributor Author

This PR is focused- there's no difference between the types of changes made for one module versus the other- and it's already fairly small. It's not at all clear why Dmitry is skeptical of one and not the other, as he only raised two minor issues and has not responded to my responses.

@burner
Copy link
Member

burner commented Jun 2, 2016

a nearly 300 line diff is not small. and it is not focused as you changed 2 files in a logically unrelated way. Having more focused PR's will help you get them in faster and I imagine you want that. Just saying.

import std.meta;
import std.range.primitives;
import std.traits;
import std.meta; // AliasSeq, staticIndexOf
Copy link
Member

Choose a reason for hiding this comment

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

If you know what you need from std.meta why don't you actually only import that. Having them as comments behind the actual import is IMO strange.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I see

@JackStouffer
Copy link
Contributor

LGTM

…ocument symbols imported at module scope, checked with ddmd
@joakim-noah
Copy link
Contributor Author

joakim-noah commented Jun 3, 2016

Updated this PR to import all free functions for arrays from std.range.primitives- back, front, popFront, popBack, put, and save- at the top of std.string as Dmitry asked for, commented out for now of course. Clearly I didn't understand what was going on with how the compiler implemented template constraints and how these functions sometimes need the free functions for arrays, even if the tests may not always exercise that, and other times don't need them.

Thanks for pushing on this a second time, Dmitry, let me know if there's anything else. I'll go back and fix the previous modules where this mistake might have been made too.

@DmitryOlshansky
Copy link
Member

Auto-merge toggled on

@DmitryOlshansky DmitryOlshansky merged commit d80f31e into dlang:master Jun 3, 2016
@joakim-noah joakim-noah deleted the imports branch June 23, 2016 07:15
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.

7 participants