[Rd] Re: backtick notation
Gabor Grothendieck
ggrothendieck at volcanomail.com
Thu Aug 7 11:43:54 MEST 2003
> > assign and as.name are fairly limited. For example, if you have a list or
> > data frame whose name is syntactically invalid it is quite difficult to
> > access or modify its columns.
>
> Yes. `weight in kg`[101]<-55 is pretty difficult to do with get() and
> assign() and lm(`weight in kg`~I(`height in m`^2)) is tricky too. The
> use is sort of similar to the single quotes in shell programming (but
> not quite). The choice of the backtick as quoting delimiter was mostly
> because that was the only one available....
Good point about the difficulty of using assign and get.
This leads to additional questions:
- is it desirable to make it easy to work with non-synactic names?
- if the previous point is yes, then is this use sufficiently
important to warrant a new syntactic element, viz. backquote?
For example, extending perhaps as.name could be extended so that
it can be used on the left hand side of an assignment like this:
as.name("height in m2")^2 or as.name("weight in kg")[101]<-55
- how far can this feature be pushed? For example, backtick quoted
names might be usable in string literals as in perl:
print("variable x is `x` and variable y is `y`") or
download.file("http://www.xyz.com?a=`a`&b=`b`")
I am not sure what the answers to these questions should be
but in order to combat excessive growth of the syntax a new
syntax addition usually is made to climb a higher barrier than
a feature which does not.
More information about the R-devel
mailing list