setPragma: Function that returns a pragma

Description Usage Arguments Details Value Warning Author(s) References See Also Examples

Description

setPragma allows for the use of pragma (also sometimes called directives or keywords. These allow assigning arbitrary functionality without having to use R's standard function call syntax i.e. with parens, resulting in cleaner code.

Usage

1

Arguments

name

The name given to the pragma/directive.

fun

A function providing the functionality to be executed. The function should have no arguments.

Details

Pragmas are useful for implementing assigning a small bit code that requires no parameters. Pragmas are implemented as object in their own unique class. The default (show) method is set to the user-supplied function. When, during the course of the program flow, the pragma is used, the arbitrary functionality is executed.

setPragma departs significantly from standard R language conventions in which every action appears as a function and side-effects are assiduously avoided.

Value

An object that when encountered in the flow of the program will execute the supplied function without the need for parenthesis. The object should be assigned to a KEYWORD that can then be exported from a package.

Warning

setPragma departs significantly from standard R language conventions in which every action appears as a function and side-effects are assiduously avoided.

Author(s)

Christopher Brown

References

http://en.wikipedia.org/wiki/Pragma

http://en.wikipedia.org/wiki/Directive_(programming)

See Also

Nothing to see here, move along.

Examples

1
2
3
4
5
6
   
   ## Not run:  
     setPragma( "KEYWORD", function() { cat( "Do Something Special.\n" ) } )
     KEYWORD  
   
## End(Not run)

pragma documentation built on May 1, 2019, 8:18 p.m.

Related to setPragma in pragma...