Is there a way to use two ‘…’ statements in a function in R?

An automatic way: foo.plot <- function(x,y,…) { lnames <- names(formals(legend)) pnames <- c(names(formals(plot.default)), names(par())) dots <- list(…) do.call(‘plot’, c(list(x = x, y = x), dots[names(dots) %in% pnames])) do.call(‘legend’, c(“bottomleft”, “bar”, pch = 1, dots[names(dots) %in% lnames])) } pch must be filtered from the lnames to avoid duplication in the legend call in case the user … Read more

Procedure with assumed-shape dummy argument must have an explicit interface [duplicate]

Assumed shape dummy arguments (those with (:)) require explicit interface to the procedure to be available at the call site. That means the calling code must know how exactly the subroutine header looks like. See also Module calling an external procedure with implicit interface That explicit interface can be provided in several ways 1. preferred … Read more

Define table and column names as arguments in a plpgsql function?

You must defend against SQL injection whenever you turn user input into code. That includes table and column names coming from system catalogs or from direct user input alike. This way you also prevent trivial exceptions with non-standard identifiers. There are basically three built-in methods: 1. format() 1st query, sanitized: CREATE OR REPLACE FUNCTION foo(_t … Read more

How to explain callbacks in plain english? How are they different from calling one function from another function?

I am going to try to keep this dead simple. A “callback” is any function that is called by another function which takes the first function as a parameter. A lot of the time, a “callback” is a function that is called when something happens. That something can be called an “event” in programmer-speak. Imagine … Read more