print for lists evaluates "AsIs"-elements of type "language"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

print for lists evaluates "AsIs"-elements of type "language"

Andreas Kersting
Consider the following code snippets:

 > list(quote(1 + 1), I(quote(1 + 1)))
[[1]]
1 + 1

[[2]]
[1] 2  # should also be 1 + 1!?

 > str(list(quote(1 + 1), I(quote(1 + 1))))
List of 2
  $ : language 1 + 1
  $ : language + 1 1  # why is this line different from the one above?
   ..- attr(*, "class")= chr "AsIs"

 > quote(1 + 1)
1 + 1

 > I(quote(1 + 1))
1 + 1  # OK

 > str(quote(1 + 1))
  language 1 + 1

 > str(I(quote(1 + 1)))
  language + 1 1  # again different
  - attr(*, "class")= chr "AsIs"


This inconsistency is particularly striking when printing the individual
elements of a list works but printing the whole list does not:

 > l <- list(quote(length(a)), I(quote(length(a))))

 > l[[1]]
length(a)

 > l[[2]]
length(a)

 > l
[[1]]
length(a)

[[2]]
Error in print(length(a)) : object 'a' not found


Should we consider this a bug? If so, I can add it to Bugzilla.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel