r_open_hook(+Alias, -Rserve) is semidet[multifile, library(r/r_serve)]
Hook that is used to translate Alias into an R connection. This is called for R references if the argument is not an Rserve handle, nor an existing alias. The hook may create R on demand. One of the use cases is SWISH, where we want thread-local references to R and we want to create the R connection on the first reference and destroy it as the query dies.
 rserve:r_open_hook(+Name, -R)[multifile, library(r/r_call)]
Called for lazy creation to the Rserve server. Connections are per-thread. The destination depends on settings:
Unix domain socket
If rserve:socket is defined and not empty, it is taken as the path to a Unix domain socket to connect to.
TCP/IP socket
Else, if rserve:port and rserve:host is defined, we connect to the indicated host and port.

After the connection is established, the session can be configured using the hook r_init_session/1. The default calls r_setup_graphics/2 to setup graphics output to send SVG files.