Thread View: gmane.comp.ai.prolog.swi
1 messages
1 total messages
Started by Jan Wielemaker
Mon, 22 Apr 2002 10:00
Re: tail recursion not working?
Author: Jan Wielemaker
Date: Mon, 22 Apr 2002 10:00
Date: Mon, 22 Apr 2002 10:00
63 lines
1960 bytes
1960 bytes
From jan@swi.psy.uva.nl Mon Apr 22 18: 00:19 2002 List-Unsubscribe: <mailto:prolog-request@swi.psy.uva.nl?subject=unsubscribe> List-Help: <mailto:prolog-request@swi.psy.uva.nl?subject=help> Phone: +31 - 20 - 525 6121 Precedence: list X-Loop: prolog@swi.psy.uva.nl List-Post: <mailto:prolog@swi.psy.uva.nl> List-Subscribe: <mailto:prolog-request@swi.psy.uva.nl?subject=subscribe> X-Status: N Resent-Sender: prolog-request@swi.psy.uva.nl X-Mailing-List: <prolog@swi.psy.uva.nl> archive/latest/1992 Status: R > I'm running swipl v 5.0.0 on Debian linux. > > I've got a simple predicate: printstring > > printstring([]) :- !. > printstring('') :- !. > > printstring(Atom) :- > atom(Atom), !, write(Atom). > > printstring([H|T]) :- > put(H), !, printstring(T). > > when I print a big string (say 4 or 5k) I get a local stack error. I'm > running a little script that works like this: > > #!/usr/bin/swipl -O -t go(1) -s > > :- set_prolog_flag(tail_recursion_optimisation,true). > :- ensure_loaded('myloader'), load. > > > What am I doing wrong? (besides using lists of codes instead of string > objects :-)) Thats fine (in most cases). I don't really know. There is no need to do set_prolog_flag(tail_recursion_optimisation,true), as this is (of course) the default. This will run out of stack in debug mode (as going to debug mode disables last call optimization), but in normal mode there is no limit (to be sure, I tested using a 25000 element string and there was indeed no problem). Please send (me) a complete program to reproduce it. --- Jan ---------------- * To UNSUBSCRIBE, please use the HTML form at http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist or send mail to prolog-request@swi.psy.uva.nl using the Subject: "unsubscribe" (without the quotes) and *no* message body. ** An ARCHIVE of this list is maintained at http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads