Skip to content

Alpha renaming, yay #3394

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

Merged
merged 3 commits into from
Jun 9, 2015
Merged

Alpha renaming, yay #3394

merged 3 commits into from
Jun 9, 2015

Conversation

andralex
Copy link
Member

@andralex andralex commented Jun 8, 2015

Now Algebraic can be used for creating self-referenced types. Refer to https://issues.dlang.org/show_bug.cgi?id=9608 for more motivation (probably this ought to close it).

/**
Performs $(LUCKY alpha renaming) of all occurrences of `From` into `To`, in one
or more types `T`. This is an advanced type manipulation necessary e.g. for
replacing the placeholder type `This` in $(XREF variant, Algebraic).
Copy link
Member

Choose a reason for hiding this comment

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

Example? Returns: ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will add Returns:. The unittest underneath is the example.

@jacob-carlborg
Copy link
Contributor

Issue 9608 is about template introspection.

@jacob-carlborg
Copy link
Contributor

In general I would recommend not mixing different type of changes in the same commit. This single commit contains both style changes for comments, replacement of $(D_PARAM) to $(D) and functionality changes.

It's easier to review if these are separate commits or even separate pull requests.

@andralex
Copy link
Member Author

andralex commented Jun 8, 2015

@jacob-carlborg Renaming types was a primary motivator for 9608. Since then there are new traits such as TemplateOf etc. But since there's also dlang/dmd#3515 I'll leave it alone.

@andralex
Copy link
Member Author

andralex commented Jun 8, 2015

@jacob-carlborg yah, variant.d is kinda difficult to review. Let me make a pass trying to break down stuff.

@andralex andralex force-pushed the alpha-rename branch 3 times, most recently from 7a304c1 to 20ee7b7 Compare June 8, 2015 17:51
@andralex
Copy link
Member Author

andralex commented Jun 8, 2015

@jacob-carlborg
Copy link
Contributor

Looks a lot less cluttered now with the ddoc macro change as a separate commit.

@andralex
Copy link
Member Author

andralex commented Jun 8, 2015

ping

static if (functionLinkage!fun == "C")
{
result ~= "extern(C) ";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What about other linkages?

Copy link
Member

Choose a reason for hiding this comment

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

Isn't this more succinctly written as:

result ~= "extern(" ~ functionLinkage!fun ~ ") ";

Or even:

result ~= "extern(%s) ".format(functionLinkage!fun);

Copy link
Member Author

Choose a reason for hiding this comment

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

nice

@andralex
Copy link
Member Author

andralex commented Jun 8, 2015

ok, linkage added

@andralex
Copy link
Member Author

andralex commented Jun 8, 2015

ping

@WalterBright
Copy link
Member

Auto-merge toggled on

WalterBright added a commit that referenced this pull request Jun 9, 2015
@WalterBright WalterBright merged commit 061e3b1 into dlang:master Jun 9, 2015
@CyberShadow
Copy link
Member

This pull request introduced a regression:
https://issues.dlang.org/show_bug.cgi?id=15039

result ~= "ref ";
}
result ~= (ReplaceType!(X, Y, ReturnType!fun)).stringof;
static if (is(fun == delegate))
Copy link
Member

Choose a reason for hiding this comment

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

There is no way to express storage classes such as ref, out, lazy as parts of types.

Which has always been an annoying limitation.
You could alias the type first (alias RT = ReplaceType!(X, Y, ReturnType!fun);) and then use "ref RT".

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, and I used the method in #3761.

@CyberShadow
Copy link
Member

This pull request introduced a regression:
https://issues.dlang.org/show_bug.cgi?id=15168

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