Is there a way to declare function parameter types in R?

If the package has a function declaration. Parameters are declared without type, which can only be calculated at runtime when the function is called.

Is there a way to describe the parameter types of the function R so that these descriptions are available for static analysis?

Use Case: Introspection for the IDE.

==== EDIT ====

  • Annotations?
  • Meta descriptors?
  • and etc.
+4
source share
1 answer

Usually not, R is dynamically typed, which can be a big advantage or a burden. Any object in R has a course type, and you can often force them (or drop them), but I don’t think what you are asking. You might want to look into the class system ( ?class ) for some approaches. But, as a rule, it is up to the write function to check the input values ​​before using them. In addition, you may find this article interesting.

Give up ?browseEnv and maybe the code that uses it might be of interest to your project. Or RStudio ?

+1
source

All Articles