Re: [eclipse-clp-users] m_map library question

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Tue, 13 Sep 2011 01:45:22 +0200
Kostas Oikonomou wrote:
> I have the following program:
> 
> :- lib(m_map).
> 
> make4(List, M) :-
>          init(M),
>          (foreach(X,List) do
>              search(M,X,Y)
>          ).
> 
> 
> When I execute the query
> 
> [eclipse 3]: make4([1,2,3], M).
> *** Overflow of the local/control stack!
> You can use the "-l kBytes" (LOCALSIZE) option to have a 
> larger stack.
> Peak sizes were: local stack 62464 kbytes, control stack 
> 68608 kbytes
> Abort
> [eclipse 4]:
> 
> I don't understand what is going on.

You are missing a param(M) in the loop header, because you are
passing the M into the loop (the "logical loops" are a bit
unusual in that respect):

          init(M),
          (foreach(X,List),param(M) do
              search(M,X,Y)
          ).

Without this, search/3 is called with a fresh local variable M,
which causes it to loop and overflow a stack.

The compiler warned you about this danger by saying
*** Warning: Singleton local variable M in do-loop, maybe param(M) missing?


Cheers,
Joachim
Received on Tue Sep 13 2011 - 00:12:09 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST