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

Fixed style of example #3

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

marcusmueller
Copy link

While it's certainly nice that C++ allows you to not have {} to
encapsulate a function body if that body only consists of a single
statement (here: try{…}), it is not of any familiarity to C++ coders
to omit them.

Same goes for putting main's argc/argv arguments on multiple lines.

Also, defining a macro PRIVATE_SOMETHING just to use it once one line of
code below is a bit of a strange thing to do.

So, I got rid of the macro and applied the clang-format style from
https://github.com/boost-experimental/vc

While it's certainly nice that C++ allows you to not have {} to
encapsulate a function body if that body only consists of a single
statement (here: `try{…}`), it is not of any familiarity to C++ coders
to omit them.

Same goes for putting `main`'s argc/argv arguments on multiple lines.

Also, defining a macro PRIVATE_SOMETHING just to use it once one line of
code below is a bit of a strange thing to do.

So, I got rid of the macro and applied the clang-format style from
https://github.com/boost-experimental/vc
@CTMacUser
Copy link
Collaborator

I felt if everything was going to be try-ed, then there was no point implying a structure that would allow me to insert statements around the try block in the future.

And teaching the novices about function-whole try blocks is a good thing! (OK, I'm not teaching it, but making novices look it up in their C++ book, or on StackOverflow, is still good.)

@marcusmueller
Copy link
Author

I beg to differ. This is an example meant to be easy to understand; it's not meant to teach C++ syntax that people seldom come across.

(I'd give my opinion about the quality of the idea of doing single statement body blocks without brackets, but I already did so.)

@marcusmueller
Copy link
Author

Also, boost at least strives to have a common and (compared to omission of brackets in function bodies) sane style; that's why the aforementioned style file exists. I don't think individual examples should choose to diverge from that.

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.

2 participants