[Rd] tab-complete for non-syntactic names could attempt backtick-wrapping

Bill Dunlap w||||@mwdun|@p @end|ng |rom gm@||@com
Thu Mar 2 18:39:24 CET 2023


x$`string` is not the same as x$'string'.  They may act similarly now, but
they do not parse the same.

> vapply(as.list(quote(list$`component`)), typeof, "")
[1] "symbol" "symbol" "symbol"
> vapply(as.list(quote(list$"component")), typeof, "")
[1] "symbol"    "symbol"    "character"
> vapply(as.list(quote(list$'component')), typeof, "")
[1] "symbol"    "symbol"    "character"

Single and double quoted character sequences do parse to the same thing
(character) but backquoted ones parse to symbols (aka names).

-Bill

On Thu, Mar 2, 2023 at 12:39 AM Ivan Krylov <krylov.r00t using gmail.com> wrote:

> There turn out to be a few more things to fix.
>
> One problem is easy to solve: vapply() needs a third argument
> specifying the type of the return value. (Can we have unit tests for
> tab completion?)
>
> The other problem is harder: `comps` defaults to an empty string, and
> you can't have a symbol consisting of an empty string, because this
> value is internally reserved for missing function arguments. I think
> you can return(paste0(prefix, op)) if length(comps) == 0L, but this is
> still somewhat worrying. R tries to prevent empty names, so I wouldn't
> expect specialOpCompletionsHelper() to return an empty string, but I
> can't prove it right now.
>
> On the other hand, x$'a string' is the same as x$`a string`. Could we
> just drop as.name() and keep the return value being a string literal?
> I'm not sure about this, either.
>
> --
> Best regards,
> Ivan
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list