[Rcpp-devel] shallow/deep copy

Darren Cook darren at dcook.org
Thu Sep 1 02:09:34 CEST 2011

> Can I ask for specific reasons why people prefer explicit?  Any potential
> danger for not being explicit?

Hello Zhongyi,
It is hard to show in a toy example; in fact "using namespace" is best
for code examples where you want to get an idea across and not cloud it
with too much other code.

But see the below example, and imagine the "//..." bits are dozens of
lines. When you see f(x) you don't know which function will be called.
You have to stop and search up to find the currently active namespace
The bigger your project, and the more 3rd party libraries you deal with,
the more this slows you down.

See also:



#include <iostream>

namespace xx{
  double f(double x){
  return x*x;

namespace yy{
  double f(double y){
  return y+y;

void one(double x){
using namespace xx;

void two(double x){
using namespace yy;

int main (int,char**){
const double PI=3.14;
return 0;

Darren Cook, Software Researcher/Developer

http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)

More information about the Rcpp-devel mailing list