rparsing

Example of an R object that is not deparse-able


base::deparse() documentation page says:

Using control = "all" comes closest to making deparse() an inverse of parse(). However, not all objects are deparse-able even with this option and a warning will be issued if the function recognizes that it is being asked to do the impossible.

Please provide an example of an object that is not deparse-able?


Solution

  • It appears that S7 objects are not deparsable. Borrowing the example from the vignette

    library(S7)
    dog <- new_class("dog", properties = list(
      name = class_character,
      age = class_numeric
    ))
    lola <- dog(name = "Lola", age = 11)
    deparse(lola)
    # Error in deparse(lola) : 'S4SXP': should not happen - please report
    

    My guess is that such an object should be deparsable so maybe future updates may change that. Interesting deparse(dog) seems to work fine.