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

id attr on symbols and NULLs #5

Open
markbravington opened this issue Jul 25, 2012 · 0 comments
Open

id attr on symbols and NULLs #5

markbravington opened this issue Jul 25, 2012 · 0 comments

Comments

@markbravington
Copy link

parser tries to attach "id" attributes to symbols and NULLs. However, a "symbol" is, like an environment, only a reference to a single global entity (even though the symbol will be interpreted differently according to context when R is executing code containing it). Thus, putting an attribute on one instance of 'x' will put the same attribute on ALL occurrences of 'x'!

the example below looks funny because Git has decided to apply "git-flavoured markdown" to it, but the point should be clear... Example:

p <- parser( text='x;x')
p[[1]]
x
attr(,"id")
[1] 8
p[[2]]
x
attr(,"id")
[1] 8

Uh-oh; p[[2]] shouldn't have same tag (id attr) as p[[1]]! Look-up now doesn't work.

quote( x)
x
attr(,"id")
[1] 8

Big uh-oh; the symbol 'x' has globally acquired a tag!

Also, parser( text='NULL') tries to put a tag on the NULL but can't, because NULL can't have attributes. Again, there is only one "NULL" .

My suggested solution is not to tag each element directly, but instead to tag its parent element with a vector of child tags, one element for each child. NULL and symbols can't have children, so this will never try to tag illegal things AFAICS.

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

No branches or pull requests

1 participant