Open alashworth opened 5 years ago
Comment by bob-carpenter
Wednesday Jun 14, 2017 at 02:53 GMT
I asked @mitzimorris to file the issue, but wanted to add what we were discussing with @seantalts:
The operators aren't in either R or Python
The postfix form in particular has a confusing semantics (as noted in the issue).
The prefix form will actually change behavior of --x
and ++x
, which are equal to -(-(x))
and +(+(x))
and both evaluate to x
. Now they are prefix operators.
The operation is restricted to indexed variables, just like assignments, rather than everything else we have which is restricted to assignments.
The main reason we have n = n + 1
and whatnot in the code is that we are either counting or incremeting some index that isn't tracking the loop indexes.
Summary:
Add the postfix version of the increment operator "++" to Stan language for integer types, which can be in expressions or as a statement, e.g.:
The semantics of the postfix increment operator are:
The same result can be gotten from:
https://github.com/stan-dev/stan/issues/1787, which has been implemented here: https://github.com/stan-dev/stan/tree/feature/1787-compound-assign-ops-scalars
It's not clear we need this feature as well.
Description:
The "++" operator is useful when incrementing (and decrementing) counters.
Both Java and C++ (hence the name) support this operator. However R and Python don't. Java and C++ have both prefix and postfix versions of this operator, with different semantics.
Current Version:
v2.15.0