[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon, 11 Oct 2004 21:01:12 +0000 (UTC) 
Subject:Re: string library question 
From:bfulg 
Volume-ID: 

>> define fast_ack (m, n) -> result;
>>     if m == 0 then
>>        n + 1 -> result
>>     elseif n == 0 then
>>        fast_ack(m - 1, 1) -> result
>>     else
>>        fast_ack(m - 1, fast_ack(m, n - 1)) ->
 result
>>     endif
>> enddefine;
 
> So the ackermann function can get very deep into 
> recursion. That means you'll have to increase both 
> pop_callstack_lim (explained in REF PROCEDURE) and 
> popmemlim (explained in REF SYSTEM).

Okay.  It's disappointing that Poplog doesn't natively
support tail call optimization.  This particular
shootout test is designed to test a language
implementation's capacity for handling deeply
recursive
logic, so we can't rewrite it using one of the
standard
iterative variations.

> It is possible (though tricky sometimes) to
 implement
> your own tail recursion optimisation for particular 
> procedures using 'chain' (see HELP CHAIN).

Oho!  I didn't know this.  I'll play with it a bit.
The main problem with Ackermann is that it is really
a tree of recursive calls, so we have to chain in a
couple of places.

> I think you must have got confused about the 
> requirement for the 'pop11::' package prefix in 
> poplog lisp. This is not needed in pop11.

Ahh.  That must be the problem.

>> Now, the thing that's causing me so much trouble is
>> the use of the "strnumber" procedure, which is 
>> apparently defined in a "string" library according
>> to the HELP system.
 
> I have never heard of this string library. Where did
 
> you get the information? The procedure strnumber is 
> built in to pop11 as one of the core procedures, 
> defined in
>
> $popsrc/item.p
>

I think this must have been my own misinterpretation
of
the error message and the way the documentation is
structured (searching the documentation in XVed showed
me "strings/strnumber", which for some reason I took
to mean 'strings' was a library.

-Brent