The Boa Programming Guide - User-Defined Functions
While Boa strives to provide useful domain-specific types and functions for performing software mining research, anticipating all specific user needs is not feasible. This is why the language provides the ability for users to define their own functions. In this section, we outline the syntax for defining functions and demonstrate with a small example.
The general form of a user-defined function is given below:
Functions usually are assigned to variables. This is how the function can later be called. Functions declare the arguments and their types, the function's return type (if any), and provide a body for the function. The body returns values, if the function declares a return type.
As an example, imagine we want a function that takes a
and determines if any files committed in that revision have the file extension
.java'. If at least one such file exists in the
Revision, we return
true. Otherwise we return
false. The function
HasJavaFile below implements
This function is assigned to the
HasJavaFile variable. It
declares one argument named
rev of type
also declares the return type of the function to be
More examples of function declarations can be seen on the domain-specific functions page.