Apropos names.

Kurt Hornik Kurt.Hornik@ci.tuwien.ac.at
Fri, 20 Mar 1998 13:51:03 +0100 (CET)

>>>>> Peter Dalgaard BSA writes:

> (from R-core)
>> Btw, why can't object names contain a `@'?
>> -k

> Speaking of names. I've been thinking whether it would not at some
> point be wise to introduce namespaces into R. This would pretty
> obviously break a lot of S code, but it would also make it possible to
> avoid a lot of silly problems such as naming one's variables c, t, pt,
> df, rm, ...

> A plan that might work relatively smoothly could involve:

> - Separate functions from variables. We already do that to some extent
>   ("looking for object of mode function...") [At the same time, one
>   might get rid of everyone's favourite quirk: forgetting () and
>   thus listing the function instead of calling it. I know: basic
>   design, functions are just objects, etc., but really: Wouldn't it be
>   nicer to type view(ls) the few times you actually wanted to see its
>   contents?]

Or print(ls)?  But then typing the name amounts to printing the object,
etc etc.

I am not sure what `separating' would amount to.  I think that as R is
really based on Lisp/Scheme, it should be obvious that we can have
functions objects and variable objects with the same name.  Of course,
the question is what happens if we do print("xyz") if there are both a
variable and a function called `xyz'.

> - All system functions and variables are really named something like
>   sys::c() i.e. we introduce a namespace separator ::.
>   Functions/variables that are intended for general use can be made
>   public, by a special call.

Yes, this would be great.  (Of course, making use of that feature means
that such R code could no longer be used with R-.)

The rule should/could be the following:  make object `obj' in
environment "package:xxx" directly accessible via "xxx::obj" rather than
having to go through get(obj, envir = "....").

A related issue is that of having modules, e.g. a `sys' module within
the base package.  It could be made ``public'' by some export/import
mechanism.  Hmm.  I think Luke had some suggestions on this about a year

> - Assignments (interactive) to an existing public name causes a
>   warning to be issued (or maybe an error).

r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch