Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.forth Subject: Re: "Forth is Sudoku for programmers" Date: Sun, 28 Aug 2016 15:25:50 -0700 Organization: A noiseless patient Spider Lines: 18 Message-ID: <87twe4pm35.fsf@jester.gateway.pace.com> References: <1e1c16c6-300f-4c4f-8590-379029478232@googlegroups.com> <065b6c2a-66ea-4f31-998d-e50f6b9ebd7e@googlegroups.com> <1f719a0d-3e81-48d3-8a49-ae06b189babe@googlegroups.com> <878tw1xi2y.fsf@jester.gateway.pace.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="590ea01354cf4bcbcd857d7ebbd88128"; logging-data="5945"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193hdQdsefa6UjylKRXqXmE" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:uELAfr1KW0kYllXBla5bH0594Zk= sha1:k+zsz1OJ4Kfc8bvxL8kUFoKn3QA= Xref: csiph.com comp.lang.forth:50529 albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes: >>In Forth without garbage collection, the best I see as feasible is to >>allocate those closures on the locals or return stack, so they go away >>when the outer function cleans up and returns. > > This is c-thinking: "keep your locals with the return address because > we've only one stack". .. Data belongs on the data stack. I get > annoyed when the first thought is locals (no way!) or the return stack > (limited size, except on gforth for Those Who Know The Ways). Store > temporary data on the data stack. Unless. We were talking how to deal with quotations (closures) that capture locals from the parent scope. So locals are already in play. The idea of a quotation is that it puts an xt on the data stack and doesn't leave other stuff there. So the captured locals have to go someplace else. Some Forths use the return stack to hold locals, so in such systems the return stack is a reasonable place for the closure enrivonment. Gforth has a separate locals stack, so that's another place to put it.