Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tags.scm should probably recognize functions with string names on the LHS #143

Open
DavisVaughan opened this issue Sep 13, 2024 · 3 comments · May be fixed by #147
Open

tags.scm should probably recognize functions with string names on the LHS #143

DavisVaughan opened this issue Sep 13, 2024 · 3 comments · May be fixed by #147

Comments

@DavisVaughan
Copy link
Member

DavisVaughan commented Sep 13, 2024

Like "$<-.data.table" in data.table
https://github.com/Rdatatable/data.table/blob/4d42cdc4f73084390eccc589e726519556c1f8a1/R/data.table.R#L2257-L2264

Screenshot 2024-09-13 at 3 26 59 PM

Not sure exactly what we should tag as the @name, probably just the whole string including the string delimiters? I think if we naively drop the delimiters and use the string_content we could have issues in the case of "name \" with dquote" because you end up with this \ in the captured text that would have to be unescaped to get name " with dquote. Seems a little complicated.

Then again, maybe if it works better in the 99% case with string_content, we should just do that and be ok with problems in the 1% case?

@kevinushey
Copy link
Collaborator

kevinushey commented Sep 16, 2024

I'm also on board with just using string_content. It also allows us to discount the delimiter, since these all do the same thing:

foo <- 1
"foo" <- 1
'foo' <- 1
`foo` <- 1

and it's more in line with the "truth", which is a variable called foo is created, regardless of its delimiters.

Not to mention, raw strings 😅

@MichaelChirico
Copy link

Yea, raw strings are a huge pain:

R"----------(why is this allowed?)----------" <- \(x) x

`why is this allowed?`(2)
# [1] 2

@MichaelChirico
Copy link

MichaelChirico commented Sep 26, 2024

Probably a separate bug, but I notice there's no support for right-assigned functions:

(function(x) { x }) -> foo
foo(2)
# [1] 2

This is a monstrosity (in my ever-so humble opinion), but does come up in CRAN packages:

https://github.com/cran/symbol.equation.gpt/blob/b9c5722f84da9b3464baef121ebd6c0cd8f26689/R/aaa.R#L15-L22

Note that due to operator precedence ()-wrapping is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants