<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <link href="chrome://translator/skin/floatingPanel.css"
      type="text/css" rel="stylesheet">
  </head>
  <body bgcolor="#FFFFFF" text="#000099">
    <br>
    <div class="moz-cite-prefix">On 11/22/2012 05:38 AM, Glynn Clements
      wrote:<br>
    </div>
    <blockquote
      cite="mid:20653.44108.388773.936857@cerise.gclements.plus.com"
      type="cite">
      <pre wrap="">
Paulo van Breugel wrote:

</pre>
      <blockquote type="cite">
        <blockquote type="cite">
          <pre wrap="">The limit would depend upon the number of columns in the current
region and the amount of memory available.
</pre>
        </blockquote>
        <pre wrap="">
OK, but what I find strange is that using 2400 terms uses less then 2.5 
GB, I would not expect 2500 terms to use more then 12 GB (amount of RAM 
available) in that case.
I also tried to run a r.mapcalc with 2600 terms for a map of 15 x 19 
cells. Also here I got the message: "memory exhausted", which can 
hardly be related to lack of memory?
</pre>
      </blockquote>
      <pre wrap="">
Right. Debugging indicates that the error actually comes from the
parser, which by default limits the stack to 10000 items. This can be
overridden by defining the macro YYMAXDEPTH in mapcalc.y.

Given that it fails at just under 5000 arguments (each x,y pair adds 2
arguments), I'm assuming that each extra argument to graph() requires
2 stack levels, so the value should be just over twice the maximum
number of arguments.

With the following change, it has no problems with 5000 arguments:

        --- raster/r.mapcalc/mapcalc.y  (revision 53964)
        +++ raster/r.mapcalc/mapcalc.y  (working copy)
        @@ -12,6 +12,7 @@
         
         #define YYDEBUG 1
         #define YYERROR_VERBOSE 1
        +#define YYMAXDEPTH 100000
         
         static int syntax_error_occurred;

To be honest, I'm not sure that it's worth increasing this value in
the standard version. 5000 arguments in a function call is rather
extreme, and probably a hint that alternative approaches should be
considered.

</pre>
    </blockquote>
    What are the possible disadvantages of increasing this limit? But
    you are right, there aren't probably many user cases where more then
    5000 arguments are used. And as my case illustrates, there might be
    better alternatives. In any case, would it be possible to change the
    error message when the limit is surpassed from the generic 'memory
    exhausted', to something along the lines of "maximum number of
    function arguments exceeded"? And possibly, this limitation could be
    mentioned in the help file?<br>
    <br>
    Thanks<br>
    <br>
    Paulo<br>
    <br>
    <div style="bottom: auto; left: 663px; right: auto; top: 566px;
      display: none;" class="translator-theme-default"
      id="translator-floating-panel">
      <div title="Click to translate"
        id="translator-floating-panel-button"></div>
    </div>
  </body>
</html>