Ok, thanks for clearing it up. But: > It's not a bug things work in ways that confuse users when they pry > into things they were not expected to pry into.... Do you have a good=
> reason to call this a bug? Well if it's intended to work that way then it's not a bug. As I said, I was computing on the language, in particular writing code = that processes the parse tree of a function. But I guess I need to avoid cer= tain gotchas like this one. Regards, Peter = = = = = = = = = = = = = Peter Dalgaard <[EMAIL PROTECTED]> = = = = = = = = = = = = = = = = = = = = = = = = = = 08/02/2007 23:39 = = = = = = = = = = = = = To = = = = = Peter-M Schumacher= /DMGGM/DMG UK/[EMAIL PROTECTED] = = = = = = = = = = = = = = = = = = = = cc = = = = = [EMAIL PROTECTED] ethz.ch, [EMAIL PROTECTED] = = = = = = = = = = = = = = = = = = = = Subject = = = = = Re: [Rd] obscure e= rror with subsetting as.list() of a function then assigning that a (PR#= 9500) = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = [EMAIL PROTECTED] writes: > Hello. I was writing some code that computes on the language and came= across > this. I can work around it, but thought you might like to know about = it. > >> f <- function(x) { NULL } >> a <- as.list(f)[[1]] >> a # ie print(a) > Error: argument "a" is missing, with no default > > Note it says *argument* "a", which is strange. In fact, and unsurpris= ingly, the bug lies > with the object itself, not with print(): > >> typeof(a) > Error in typeof(a) : argument "a" is missing, with no default >> deparse(a) > Error in deparse(a) : argument "a" is missing, with no default > > However, this does work: >> as.list(f)[[1]] > > It prints nothing, which is correct, and there is no error. So it see= ms the bug lies with > assigning a name to as.list(f)[[1]] as above, then trying to work wit= h that new object. It's not a bug things work in ways that confuse users when they pry into things they were not expected to pry into.... Do you have a good reason to call this a bug? What you're seeing is R's "missing argument object", via the default value of the formal argument x. A slightly cleaner way to get your result is > formals(f) $x > a <-formals(f)$x > a Error: argument "a" is missing, with no default Technically, the missing argument object is a zero-length variable name: > mode(formals(f)$x) [1] "name" > as.character(formals(f)$x) [1] "" Except for direct meddling with the formals(f), the only way to assign the missing argument object is via parameter passing - any other attempt to access it gives an error. So the common case is that the object is indeed a function argument. > Regards, > [EMAIL PROTECTED] > > > --please do not edit the information below-- > > Version: > platform =3D i386-pc-mingw32 > arch =3D i386 > os =3D mingw32 > system =3D i386, mingw32 > status =3D > major =3D 2 > minor =3D 4.1 > year =3D 2006 > month =3D 12 > day =3D 18 > svn rev =3D 40228 > language =3D R > version.string =3D R version 2.4.1 (2006-12-18) > > Windows XP Professional (build 2600) Service Pack 2.0 > > Locale: > LC_COLLATE=3DEnglish_United Kingdom.1252;LC_CTYPE=3DEnglish_United Ki= ngdom.1252;LC_MONETARY=3DEnglish_United Kingdom.1252;LC_NUMERIC=3DC;LC_= TIME=3DEnglish_United Kingdom.1252 > > Search Path: > .GlobalEnv, file:c:/schupl/R/myRLib/.RData, package:stats, package:g= raphics, package:grDevices, package:utils, package:datasets, package:me= thods, Autoloads, package:base > --- > > This e-mail may contain confidential and/or privileged infor...{{drop= ped}} > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- O__ ---- Peter Dalgaard =D8ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 353= 27918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 353= 27907 --- This e-mail may contain confidential and/or privileged infor...{{dropped}} ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel