Skip to content
Prev 10201 / 63424 Next

backtick notation

Gabor Grothendieck <ggrothendieck@volcanomail.com> writes:
No and yes. This has been the reason thant it wasn't implemented long
ago, but the increasing use of interfaces to non-R databases (with
non-R names) was making it desirable to have some way of using these
names, particularly in model formulas. Notice that non-valid names
have always been supported for function names and list elements.
get() would be more likely than as.name() there since it doesn't make
sense to square a symbol and y <- as.name("x") is different from y <-
get("x"). That would be workable, but it introduces an extra function
call at run time and leads to notation in model formulas which would
drive users nuts. Also it has the potential to rid us of some
unfortunate assymmetries in the language where text strings in
"non-syntactic" positions - but only there - are used to specify funny
names. Consider e.g. "foo bar" <- x vs. x <- "foo bar". Much of this
would be more logical if the identifier was put in backticks rather
than quotes. On the other hand compatibility issues probably forces us
to live with the old convention in dump() and similar places.
I wouldn't want to push it very far, and quite certainly not in that
direction (having backticks mean "value of" in one context and
"literal name" in another would be odd). It works at the level of
lexical analysis, so it is a very basic element, similar to the
%foobar% style of operator specification (there's one type of funny
name for you that has been integral to the language for quite a
while.) Of course, one could still implement string interpolation;
it's just not really related to the issue of nonstandard identifiers.
Actually, the ASCII character set puts a rather effective limit on the
number of quoting operators that one can have. The backtick was
the only symbol that wasn't already used in R, so bringing it
into play *was* considered quite carefully...