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

The 'const' mystery #53

Open
mikewesthad opened this issue Sep 27, 2013 · 1 comment
Open

The 'const' mystery #53

mikewesthad opened this issue Sep 27, 2013 · 1 comment

Comments

@mikewesthad
Copy link
Contributor

So @abrahamavnisan brought up a question as to why, in the openFrameworks documentation, certain functions have their inputs defined with the const keyword (e.g. ofStringSplit() takes a "const string& str" as an input).

I was looking up something else and stumbled upon an explanation of const correctness. Short version - it guarantees that, if we are passing in a variable to a function, that our copy of the variable will be unaffected by the function call. Very important information for us since we are using someone else's (oF) function, and we aren't familiar with how it is implemented: whatever happens behind the scenes, we can rest assured that the function won't muck with our variables.

@bakercp
Copy link
Member

bakercp commented Sep 27, 2013

@mikewesthad you've got the basics (and most important bits).

This is a whole can of worms that you've discovered. I'll be happy to give you the low-down on const-correctness tomorrow and how it is ... not well-demonstrated in the openFrameworks core (yet). Just make sure to remind me if I don't remember tomorrow. We are going to get into some pointers, references, const, etc tomorrow.

See here for some of my pending work on const-correctness in the oF core ....

openframeworks/openFrameworks#2493

Also, this may be of interest. It's the 1.0 Roadmap we created in Japan at the end of the summer. It mentions the need for const-correctness throughout the core.

https://docs.google.com/document/d/1GjgjQZCHTcOD3cT9OFSl0AZ1nhfYwwvxTl5L4OJE6qA/edit

:)

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

No branches or pull requests

2 participants