Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what "equal return types" means.
And what you mean by "align" in the PR comment...
Can you clarify what you're trying to show here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I wanted to clarify that it is not enough to just return a func type e.g.
Secondly I wanted to add that the return type of the outer function must match the inner function.
I hope it makes more sense now. Pitty that my take was not comprehensible enough so it made sense at first sight. Do you have a better idea to describe it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying.
I think the current text is ok unless we figure out a better way to say it.
As a general guideline, it's a non-goal of gobyexample to explain any nuance of the language's syntax. We assume the user read some basic tutorials and the Tour of Go already, and understands basic syntax and semantics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. My bad then. Didn't know that because some basic syntax was explained in other parts as well like here:
I just wanted to share my experience what occurred to me when I ran over the examples and tried to implement them myself. To document that
func
is not a valid return type in case the wrapped function returns or expects parameters.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that's the thing, gobyexample shows you how to do it properly. That's the "by example" part. The same applies to the
make(map...
example.What I'm saying is that the accompanying comments don't have to explain the language / repeat the spec. The examples is what matter.
I don't object to improving the comment here slightly, it's just that your suggestion was (IMHO) less clear than the current text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eliben sorry for my late reply.
How about this?
From:
To:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't sound true; "function signature" = parameters + return values, and these don't necessarily have to match.
What you really want to say is something about the return type of the outer function being the type of the internal function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely right. The parameters are no constraint. What about this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not amazing, because of the ambiguity of "and". It reads like the return value of outer = return value of inner, whereas we want return value of outer = inner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. What about these two:
A
B