[GRASS-dev] [GRASS GIS] #2986: r.mapcalc with same variable on LHS and RHS

GRASS GIS trac at osgeo.org
Mon Jun 20 15:02:50 PDT 2016

#2986: r.mapcalc with same variable on LHS and RHS
  Reporter:  mankoff      |      Owner:  grass-dev@…
      Type:  defect       |     Status:  closed
  Priority:  major        |  Milestone:  7.0.4
 Component:  Docs         |    Version:  7.0.3
Resolution:  fixed        |   Keywords:  r.mapcalc
       CPU:  Unspecified  |   Platform:  Unspecified

Comment (by glynn):

 Replying to [comment:12 wenzeslaus]:

 > Do I understand it correctly that re-assigning a variable inside sub-
 expression like in the following example is OK?

 I think so.

 The parser replaces variable names with a reference to the last binding
 for that variable, and bindings are appended to the list after the binding
 is parsed (so if the RHS contains a reference to the LHS, it will refer to
 the previous binding rather than the one being parsed).

 So in that example, you have two distinct variables named "x". The first
 sub-expression assigns the first one, the second sub-expression reads the
 first and assigns to the second, the third sub-expression reads the

Ticket URL: <https://trac.osgeo.org/grass/ticket/2986#comment:13>
GRASS GIS <https://grass.osgeo.org>

More information about the grass-dev mailing list