From p.dalgaard at biostat.ku.dk  Fri Oct 29 23:53:34 2004
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Fri Oct 29 23:53:51 2004
Subject: [Rd] (inappropriate) manipulation of expression objects causes
	segfault (PR#7326)
In-Reply-To: <20041029213351.DAF0C1134D@slim.kubism.ku.dk>
References: <20041029213351.DAF0C1134D@slim.kubism.ku.dk>
Message-ID: <x24qkdi42p.fsf@biostat.ku.dk>

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


[Rd] (inappropriate) manipulation of expression objects causes segfault (PR#7326)
Peter Dalgaard