"my2" <- function(x, minx=min(x)) { # Here is a smart function
    x <- x  # Needed for nested calls, e.g., bs(scale(x))
    if(smart.mode.is("read")) {
        return(eval(smart.expression))
    } else
    if(smart.mode.is("write"))
        put.smart(list(minx=minx, match.call=match.call()))
    (x-minx)^2
}
attr(my2, "smart") <- TRUERun the code above in your browser using DataLab