TIBCO Spotfire S+ was not designed to explicitly hide S code. The only way to do this is to rewrite your functions in C code and then call it from S+ with the .C or .Call function. For more information please see Chapter 5 "Interfacing with C and Fortran Code" of the S+ 8.2 Application Developer's Guide. This manual is available online at:
https://docs.tibco.com/pub/spotfire_s_plus/8.2.0_november_2010/pdf/TIB_sf_s+_8.2.0_app_dev_guide.pdfThere are a few additional approaches which could be taken:
1. Restrict access to the machines on which the confidential code resides, both physically and electronically.
2. Code proprietary functions in S script files (*.ssc or *.q) and encrypt the script files using 3rd-party encryption software. When those functions are needed, decrypt and source the files into S+. At the end of the session, delete the functions from S+. One could use a .Last() function to delete the functions on exit from an S+ session.
3. Maintain proprietary functions in a separate database, to be attached only when needed. Restrict access to that database using standard computer security methods, possibly encrypting it when not in use.
4. Maintain proprietary functions in a package, to be attached only when needed. Restrict access to that package using standard computer security methods, possibly encrypting it when not in use.
To do this, create a binary version of the package in order for the objects to not be included as ASCII dumps in the R directory inside of the package. (All source packages have an R (and/or data) directory with ASCII dumps of the objects.)
Please note that even if a binary package is created, the R-ex directory of a package contains the examples section from each of the Rd (help) files in the package. The template Rd files for each function in the package include the function source as the example. The solution here is to create a real Rd file (one that has real examples of the functions use).
5. Give the proprietary functions cryptic or misleading names, so as not to attract attention from someone casually browsing a directory.
6. Edit print.default(). Please see the following example:
Write the function:
ff_function()
{
a_5
return(a)
}
Edit print.default:
> Edit(print.default)
Add the following line at the beginning of the print.default function, just after the first "{":
if (is.function(x)) return(invisible(NULL))
Run this script. This will update the function and place a copy in your working directory. That new copy of print.default will mask the system copy so long as it is in a database attached ahead of the supplied copy of print.default.
The function should now be hidden from users:
> ff
> ff()
[1] 5