On 29 Oct 2004, Peter Dalgaard wrote:
> 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
That's not the issue: VectorAssign has identical code for the vector list and expression cases. The issue is in SubassignTypeFix which says
case 2010: /* expression <- logical */ /* Note : No coercion is needed here. */ /* We just insert the RHS into the LHS. */ /* FIXME: is this true or should it be just like the "vector" case? */
and at level=1 the FIXME is correct.
Brian
-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-develReceived on Tue Nov 02 06:10:26 2004
This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:26 EST