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

Issue 11123 - std.getopt should support function callbacks. #1601

Merged
merged 1 commit into from Sep 27, 2013
Merged

Issue 11123 - std.getopt should support function callbacks. #1601

merged 1 commit into from Sep 27, 2013

Conversation

ghost
Copy link

@ghost ghost commented Sep 26, 2013

@monarchdodra
Copy link
Collaborator

I expected you'd fix this quickly. Looks good.

@ghost
Copy link
Author

ghost commented Sep 26, 2013

Someone on IRC asked for it, saying they thought that C-style argument handling was supported (meaning "call this function when an argument is passed").

@ghost
Copy link
Author

ghost commented Sep 27, 2013

It's green, yay. Any objections on pulling this?

is(typeof(receiver) == delegate) &&
enum isCallbackWithLessThanTwoParameters =
(is(typeof(receiver) == delegate) ||
is(typeof(*receiver) == function)) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can't put both of these on the same line? The line break seems arbitrary to me, especially when both tests constitute a single "conditional block".

Copy link
Author

Choose a reason for hiding this comment

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

Sure thing.

@@ -504,7 +504,8 @@ void handleOption(R)(string option, R receiver, ref string[] args,
// string receiver
*receiver = to!(typeof(*receiver))(val);
}
else static if (is(typeof(receiver) == delegate))
else static if (is(typeof(receiver) == delegate) ||
is(typeof(*receiver) == function))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd have thought you'd have done this one too...

Copy link
Author

Choose a reason for hiding this comment

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

I'm trying to make the code consistent, this line will be way too wide compared to the other code that surrounds it.

monarchdodra added a commit that referenced this pull request Sep 27, 2013
Issue 11123 - std.getopt should support function callbacks.
@monarchdodra monarchdodra merged commit 1ceddc4 into dlang:master Sep 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants