Created
July 1, 2015 00:00
-
-
Save pniedzielski/28adac9b92b3321666f2 to your computer and use it in GitHub Desktop.
Namespaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* We have three ways of importing the literals in something designed | |
like the standard library: */ | |
void my_function() { | |
/* Means "now all of foo is the most important thing in this | |
function" -> implies shift from what was most important outside | |
this function */ | |
using namespace foo; | |
// OR | |
/* Means "now the user-defined literals from foo are important" -> | |
implies everything else is like outer scope | |
*/ | |
using namespace foo::literals; | |
// OR | |
/* Means "now the _abc user-defined literal from foo is important" */ | |
using namespace foo::literals::abc_literals; | |
/* See how these all mean slightly different things, even though | |
they all let you type 123_abc and get the one from foo? My | |
contention is that these slight shades of meaning, when used | |
correctly, aid tremendously in reasoning about software (my | |
experience with Perl, C++, and Haskell has taught me this). I | |
should probably write this up, because I think we agree on the | |
what I consider the fundamental idea (we want our software to be | |
readable), but the path from there to here may not be immediately | |
apparent. */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment