Re: [Rd] Unexpected behavior of identical() with language objects

2014-10-29 Thread Duncan Murdoch
seq_along(part)) part[[i]] <- recurse(part[[i]]) > } > part > } > body(fn) <- recurse(body(fn)) > > if( !is.fun) { > return( body( fn)) > } else { > return( fn) > } > } > #> identical( rmsrc( quote({a})), rm

Re: [Rd] Unexpected behavior of identical() with language objects

2014-10-29 Thread Mark.Bravington
for (i in seq_along(part)) part[[i]] <- recurse(part[[i]]) } part } body(fn) <- recurse(body(fn)) if( !is.fun) { return( body( fn)) } else { return( fn) } } #> identical( rmsrc( quote({a})), rmsrc( quote({a}))) #[1] TRUE > -----Origin

Re: [Rd] Unexpected behavior of identical() with language objects

2014-10-29 Thread Winston Chang
Ah, I was using identical() to compare two function bodies. It returns FALSE even when you remove srcrefs from the body: f1 <- function(x) { if (TRUE) { x } } f2 <- function(x) { if (TRUE) { x } } f1b <- body(f1) f2b <- body(f2) attributes(f1b) <- NULL attributes(f2b) <- NULL # The bodies loo

Re: [Rd] Unexpected behavior of identical() with language objects

2014-10-29 Thread Hadley Wickham
>> Is this expected behavior? I can't seem to find anything in the help >> for identical that relates to this. >> > It's not in ?identical, but ?Paren gives you some pointers. > str(quote((a))) and str(quote({a})) are also informative. Yes, looks like srcrefs are to blame: x <- quote({ a }) y <-

Re: [Rd] Unexpected behavior of identical() with language objects

2014-10-29 Thread Lorenz, David
Fascinating! I tried the comparisons with all.equal(), expecting a description of the difference, but TRUE was returned in both cases. Dave On Wed, Oct 29, 2014 at 3:26 PM, Winston Chang wrote: > I ran into this and found the result very surprising: > > identical( quote({ a }), quote({ a }) )

Re: [Rd] Unexpected behavior of identical() with language objects

2014-10-29 Thread Joshua Ulrich
On Wed, Oct 29, 2014 at 3:26 PM, Winston Chang wrote: > I ran into this and found the result very surprising: > > identical( quote({ a }), quote({ a }) ) > # FALSE > > It seems related to curly braces. For example, parens work fine: > identical( quote(( a )), quote(( a )) ) > # TRUE > > Is this