Sorry, I meant I think it is R_MissingArg, not R_UnboundValue. Again though this is just a guess (though somewhat easily tested).
~G On Mon, Oct 21, 2013 at 1:30 PM, Gabriel Becker <[email protected]>wrote: > Jeroen, > > The problem seems to be that you are grabbing a symbol that doesn't have a > name. I suspect its R_UnboundValue, but I don't have time to check right > now. Anyway, take a look at this: > > > .Internal(inspect(as.list(lm)$data)) > @1cada98 01 SYMSXP g1c0 [MARK,NAM(2)] "" (has value) > > And compare it with this: > > x = as.symbol("y") > > x > y > > .Internal(inspect(x)) > @2204db8 01 SYMSXP g1c0 [MARK,NAM(1)] "y" > > So you have attemtped to assign a symbol pointing to the variable "" to > foo. My guess is that there is a specific way arguments are assigned values > within a closure that allows this to happen when a function is being > called, which allows for "missing" argument values, but those special > mechanisms/protections aren't available outside of that situation using > standard assignment mechanics and so R is getting confused. > > AFAICT the assignment to foo should probably just be failing outright. > > ~G > > > On Mon, Oct 21, 2013 at 12:31 PM, Jeroen Ooms > <[email protected]>wrote: > >> When a variable is assigned the empty symbol, looking up the variable >> results in an error message that looks like a function call: >> >> > foo <- as.list(lm)$data >> > ls() >> [1] "foo" >> > foo >> Error: argument "foo" is missing, with no default >> > get("foo") >> Error in get("foo") : argument "foo" is missing, with no default >> > rm("foo") >> >> I ran into this problem when writing a function to serialize functions by >> their list representation, e.g. as.list(lm). It is quite hard to debug >> because of the confusing error message. I would have expected that: >> >> foo == substitute() >> >> just like >> >> as.list(lm)$data == substitute() >> >> Is this intended behaviour? >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> [email protected] mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> > > > > -- > Gabriel Becker > Graduate Student > Statistics Department > University of California, Davis > -- Gabriel Becker Graduate Student Statistics Department University of California, Davis [[alternative HTML version deleted]] ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
