11# Void Functions
22
33Stan does not technically support functions that do not return values.
4- It does support two types of statements that look like functions, one
5- for printing and one for rejecting outputs. Documentation on these
6- functions is included here for completeness. The special keyword
7- ` void ` is used for the return type of void functions, because they
8- behave like variadic functions with void return type, even though they
9- are special kinds of statements.
4+ It does support two types of statements, one printing and one for rejecting
5+ outputs.
106
117Although ` print ` and ` reject ` appear to have the syntax of functions,
128they are actually special kinds of statements with slightly different
@@ -16,6 +12,10 @@ are the the only constructs to accept string literals (e.g., `"hello
1612world"`) as arguments. Third, they have no effect on the log density
1713function and operate solely through side effects.
1814
15+ The special keyword ` void ` is used for their return type because they behave
16+ like variadic functions with void return type, even though they are special
17+ kinds of statements.
18+
1919``` {r results='asis', echo=FALSE}
2020if (knitr::is_html_output()) {
2121cat(' * <a href="print-statement.html">Print Statement</a>\n')
@@ -37,7 +37,7 @@ or the R console in RStan).
3737` void ` ** ` print ` ** ` (T1 x1,..., TN xN) ` <br >\newline
3838Print the values denoted by the arguments x1 through xN on the output
3939message stream. There are no spaces between items in the print, but a
40- line feed (LF; Unicode U+000A; C++ literal ` '\{n} ' ` ) is inserted at
40+ line feed (LF; Unicode U+000A; C++ literal ` '\n ' ` ) is inserted at
4141the end of the printed line. The types ` T1 ` through ` TN ` can be any of
4242Stan's built-in numerical types or double quoted strings of ASCII
4343characters.
@@ -58,7 +58,7 @@ context in which it occurs).
5858Reject the current iteration and print the values denoted by the
5959arguments x1 through xN on the output message stream. There are no
6060spaces between items in the print, but a line feed (LF; Unicode
61- U+000A; C++ literal ` '\{n} ' ` ) is inserted at the end of the printed
61+ U+000A; C++ literal ` '\n ' ` ) is inserted at the end of the printed
6262line. The types ` T1 ` through ` TN ` can be any of Stan's built-in
6363numerical types or double quoted strings of ASCII characters.
6464
0 commit comments