puzzling behaviour of identical function
I am puzzled by the following seemingly contradictory calls to the function identical. Below is a minimal example, that reproduces them:
sessionInfo()
R version 3.2.0 (2015-04-16) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.9.5 (Mavericks) locale: [1] C attached base packages: [1] stats graphics grDevices utils datasets grid methods [8] base loaded via a namespace (and not attached): [1] compiler_3.2.0 tools_3.2.0 memoise_0.2.1 digest_0.6.8
readLines("tmp.R")
[1] "if (identical(function(x)1,function(x)1)) cat(\"Identical!\\n\") else cat(\"Not Identical!\\n\")"
sys.source("tmp.R", envir=new.env(parent=baseenv()))
Identical!
if (identical(function(x)1,function(x)1)) cat("Identical!\n") else cat("Not Identical!\n")
Not Identical! Can anyone explain why I get a false value from the command line but true if I use sys.source?
Kind Regards Munawar Cheema