Turns on/off a full fledged checking of calls to check_arg. If on, it enables the developer mode which checks extensively calls to check_arg, allowing to find any problem. If a problem is found, it is pinpointed and the associated help is referred to.

setDreamerr_dev.mode(dev.mode = FALSE)

Arguments

dev.mode

A logical, default is FALSE.

Details

Since this mode ensures a detailed cheking of all check_arg calls, it is thus a strain on performance and should be always turned off otherwise needed.

See also

Author

Laurent Berge

Examples


# If you're new to check_arg, given the many types available,
# it's very common to make mistakes when creating check_arg calls.
# The developer mode ensures that any problematic call is spotted
# and the problem is clearly stated
#
# Note that since this mode ensures a detailed cheking of the call
# it is thus a strain on performance and should be always turned off
# otherwise needed.
#

# Setting the developer mode on:
setDreamerr_dev.mode(TRUE)

# Creating some 'wrong' calls => the problem is pinpointed

test = function(x) check_arg(x, "integer scalar", "numeric vector")
try(test())
#> Error : in check_arg(x, "integer scalar", "numeric vector"): 
#> Argument '.type' could not be identified: several character literals were
#> found. There is a very big problem in the call to check_arg which should
#> consist of only i) argument names and ii) the type. Please have a look at
#> the details/examples/vignette.

test = function(...) check_arg("numeric vector", ...)
try(test())
#> Error : in check_arg("numeric vector", ...): 
#> Problem in the arguments passed to check_arg(). If you want to check '...',
#> then '...' must be the first argument of check_arg (currently it is the
#> second).

test = function(x) check_arg(x$a, "numeric vector")
try(test())
#> Error : in check_arg(x$a, "numeric vector"): 
#> You cannot check list elements in check_arg, but you can in check_set_arg.
#> Please refer to Section XIII) in the examples.

test = function(x) check_arg(x, "numeric vector integer")
try(test())
#> Error : in check_arg(x, "numeric vector integer"): 
#> Problem in the type. In the main class 'vector' [fully equal to 'numeric
#> vector integer'], the following keyword(s) will not be used: 'numeric'.
#>  Further, another sub-type was found in this remainder ('numeric'), this is
#>  not allowed. If you want to check several sub-types, please put them in
#>  parentheses after the main class. See Section XI) in the examples.

test = function(x) check_arg(x, "vector len(,)")
try(test())
#> Error : in check_arg(x, "vector len(,)"): 
#> Problem in the type. In the main class 'vector' [fully equal to 'vector
#> len(,)'], the len restriction is ill-formed. It MUST be of the type: A)
#> len(a, b), len(, b), len(a, ) or len(a), with a and b integers. Or B)
#> len(data) or len(value). See Section IV) in the examples. Currently it
#> contains no element in the parentheses.

# etc...

# Setting the developer mode off:
setDreamerr_dev.mode(FALSE)