Global variable in functions block

I want a global variable (which is a vector in this case), which I can declare once and use throughout my functions block. The compiler is not accepting it. Is there such provision in stan?

No. There are no global variables.

We, the Stan development team, have discussed things like this, but it’s never gotten further. Part of it is because the cons outweigh the pros, but also because it’s lower priority (even if we were to design it properly) and we’re just tackling other things.

We’re always looking for more contributors. If that’s of interest, it would help to explain why it’s useful, how exactly that would be specified. If you have time to work on it to help Stan, then even better!

I think at most we’d add closures so that function bodies could implicitly depend on all variables in scope.

1 Like