Re: [Rd] force promises inside lapply

2017-07-31 Thread William Dunlap via R-devel
quote(expr) will make no changes in expr, it just returns its one argument, unevaluated. substitute could be used in your lapply(..., library) example to give library a name instead of a character string for an input (which might be necessary if the character.only argument were not available)

Re: [Rd] force promises inside lapply

2017-07-31 Thread Benjamin Tyner
Thanks again Bill; I agree that substitute is overkill here. As an aside, for cases where someone may be tempted to use substitute(), it seems quote() might be a safer alternative; compare > lapply(list(1), function(y) c(quote(y), substitute(y))) [[1]] [[1]][[1]] y [[1]][[2]]

Re: [Rd] force promises inside lapply

2017-07-29 Thread William Dunlap via R-devel
Functions, like your loader(), that use substitute to let users confound things and their names, should give the user a way to avoid the use of substitute. E.g., library() has the 'character.only' argument; if TRUE then the package argument is treated as an ordinary argument and not passed

Re: [Rd] force promises inside lapply

2017-07-28 Thread Benjamin Tyner
Thanks Bill. I think my confusion may have been in part due to my conflating two distinct meanings of the term "evaluate"; the help for force says it "forces the evaluation of a function argument" whereas the help for eval says it "evaluates the ... argument ... and returns the computed

Re: [Rd] force promises inside lapply

2017-07-28 Thread William Dunlap via R-devel
1: substitute(), when given an argument to a function (which will be a promise) gives you the unevaluated expression given as the argument: > L <- list(a=1, b=2, c=3) > str(lapply(L, function(x) substitute(x))) List of 3 $ a: language X[[i]] $ b: language X[[i]] $ c: language X[[i]] The 'X'

[Rd] force promises inside lapply

2017-07-28 Thread Benjamin Tyner
Hi, I thought I understood the change to lapply semantics resulting from this, https://bugs.r-project.org/bugzilla/show_bug.cgi?id=16093 However, would someone care to explain why this does not work? > L <- list(a=1, b=2, c=3) > str(lapply(L, function(x){ y <- substitute(x);