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

Fix remaining import deprecation messages #4016

Merged
merged 2 commits into from
Feb 22, 2016

Conversation

schveiguy
Copy link
Member

See #4015

This is the rest of them.

There are some places where it's not 100% clear whether the right call is a static import or a selective import.

This should be merged fairly quickly, because it touches a lot of files, the risk of this becoming conflicting is pretty high.

@MartinNowak
Copy link
Member

Thanks a lot.

ab = (-lhs) ^^ this.re * exp(-PI * this.im);
ar = PI * this.re + log(-lhs) * this.im;
ab = (-lhs) ^^ this.re * std.math.exp(-std.math.PI * this.im);
ar = std.math.PI * this.re + std.math.log(-lhs) * this.im;
Copy link
Member

Choose a reason for hiding this comment

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

IMO, in math-related code such as std/complex.d it's only natural to use log and PI directly, instead of the ugly FQN's. What about making this one a selective import instead?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah import std.math : cos, exp, log, sin would be a bit nicer, in fact since hijacking of local symbols was fixed import std.math would be an option as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was the trickiest file. Because std.complex has some of the exact same symbols as std.math

I asked myself the question, "what are the chances that std.complex will gain a definition for PI, log, etc.?", so I just went with the static import. There are other places I have no choice (example, sqrt).

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'll note that with new rules, the current module takes precedent over any imports, even scoped ones. So using selective imports may break later if these symbols get added.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, you're right, std.complex quite possibly may implement its own version of log, exp, etc.. But wouldn't they be adequately disambiguated by the argument type? Or would that still be a conflict under current rules?

Copy link
Member Author

Choose a reason for hiding this comment

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

The current file takes precedence I think, but not quite sure. So the compiler (I think) will stop looking for the symbol if it finds it in the current module, regardless of whether the overload would work elsewhere.

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'm wrong, I tested it out. Apparently, if you import selectively, that overrides any local module symbols. Is that the way it's supposed to work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Update: yep, dlang.org specifies this behavior. A selective import binds it to the current namespace.

I'll work on re-fixing these.

@quickfur
Copy link
Member

Other than that, LGTM. Let's get this in sooner rather than later.

@schveiguy
Copy link
Member Author

Redid some of the static imports as selective, and fixed the assert spacing.

@quickfur
Copy link
Member

LGTM

@quickfur
Copy link
Member

Auto-merge toggled on

quickfur pushed a commit that referenced this pull request Feb 22, 2016
Fix remaining import deprecation messages
@quickfur quickfur merged commit 0a885cd into dlang:master Feb 22, 2016
@schveiguy schveiguy deleted the fix_import_deprecations branch February 23, 2016 14:01
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