Skip to content

some stylistic improvements to toTypeFunction()#7754

Merged
andralex merged 1 commit intodlang:masterfrom
WalterBright:toTypeFunction
Jan 19, 2018
Merged

some stylistic improvements to toTypeFunction()#7754
andralex merged 1 commit intodlang:masterfrom
WalterBright:toTypeFunction

Conversation

@WalterBright
Copy link
Member

#7749 got merged before I reviewed it, so my review is coming in the form of a touch-up PR.

  1. Please don't invent a new formatting style for function Ddoc comments.

  2. I find default arguments make code harder to understand. Besides, this is an almost ideal use case for an out parameter. out parameters eliminate the null pointer issue, are more checkably memory safe, and the code is simpler.

  3. Reorganized the code a bit to eliminate variable tf and reduce the scope of s.

cc @UplinkCoder @JinShil

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

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.

return cast(TypeFunction)t.nextOf();
else if (t.ty == Type.Kind.pointer && t.nextOf().ty == Type.Kind.function_)
tf = cast(TypeFunction)t.nextOf();
return cast(TypeFunction)t.nextOf();
Copy link
Member

Choose a reason for hiding this comment

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

two redundant elses, but I'll let them be

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, I missed that.

@andralex andralex merged commit a3acdb8 into dlang:master Jan 19, 2018
@JinShil
Copy link
Contributor

JinShil commented Jan 19, 2018

@WalterBright, I'm sorry if you felt this was merged prematurely. But please note that the PR is actually almost 9 months old, and I assumed you were OK with it due to this comment from you in the original PR.

LGTM provided the function is documented

@WalterBright
Copy link
Member Author

I reserve the right to learn how to do things better over time :-)

@stefan-koch-sociomantic
Copy link

stefan-koch-sociomantic commented Jan 20, 2018

The comment was written a way I would write code: with indentation. I don't mind the change too much.
The default parameter was used in order to not force the caller to pass in a variable when it's not needed.
Since it was only not needed in one case, one may reasonably change that/

However after your changes toTypeFunction will be unable to go through the inliner; which I also considered when writing it.

Using multiple returns bloats the code.

I do understand that one might not value performance for trait evaluation, but that's no reason to actively degrade it.

@WalterBright WalterBright deleted the toTypeFunction branch January 20, 2018 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants