Re: [Rd] (inappropriate) manipulation of expression objects causes segfault (PR#7326)

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Sat 30 Oct 2004 - 07:53:34 EST

deepayan@stat.wisc.edu writes:

> > foo <- expression(alpha, beta, gamma)
> > foo[2]
> expression(beta)
> > foo[2] <- NA
> > foo ## or str(foo)
> Segmentation fault
>
> (Same behaviour in R 1.9.1)
>
> 'foo[[2]] <- NA' works fine, though.

Right. The NA is not important; foo[2] <- 1 crashes R just as effectively. We should likely either give an error or demote [ to [[. The latter is what happens with lists, and expressions are basically just list of call objects (or names or constants). To wit:

> x <- list(1,2,3)
> x[2] <- 1
> x
[[1]]
[1] 1

[[2]]
[1] 1

[[3]]
[1] 3

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat Oct 30 07:59:51 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:00:58 EST