Hi. I'm trying to find a systematic way to prevent assignment to names of existing functions. I've tried reassigning to the assignment operator, with mixed results. The function definition for "<-" below works as hoped for the demonstrated assignments to a and c. However, for the assignment based on the test function, it appears that the formal argument is not visible. Any suggestions?
Thanks, Tim. ------------------------------------------------------------- rm(list=ls()) "<-" <- function(x,value){ try(assign("y",x), silent=TRUE) if (exists("y", mode="function")) stop("assignment to an existing function") else eval(substitute(.Primitive("<-")(x, value)),sys.frame(sys.parent(2))) } MYLEN <- function(infile){ LEN <- nchar(infile) return(LEN) } a <- 3 c <- 3 #Error in c <- 3 : assignment to an existing function d <- MYLEN("word") #Error in nchar(infile) : object "infile" not found ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel