Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: gforth too bloated ? Date: Wed, 14 May 2014 20:02:55 -0400 Organization: Aioe.org NNTP Server Lines: 46 Message-ID: References: <4b4ea6f6-3b09-434a-a501-ff31190b9f4a@googlegroups.com> <_oedna7rFu8VYfDOnZ2dnUVZ_rGdnZ2d@supernews.com> <2014May10.123904@mips.complang.tuwien.ac.at> <7qadnesZfp6twfPOnZ2dnUVZ_qGdnZ2d@supernews.com> <2014May11.141024@mips.complang.tuwien.ac.at> <2014May13.184005@mips.complang.tuwien.ac.at> <47qdnXip89VGwe_OnZ2dnUVZ_jadnZ2d@supernews.com> <2014May14.140323@mips.complang.tuwien.ac.at> <7xha4sl4hf.fsf@ruckus.brouhaha.com> NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:30388 On Wed, 14 May 2014 12:17:16 -0400, Paul Rubin wrote: > I'd hope a compiler with good locals support could handle writing all > the traditional primitives directly in Forth without any special tools > or generators: > > : 2dup { x y } x y x y ; > : dup { x } x x ; > : swap { x y } y x ; > : drop { x } ; > > et cetera. These would all be defined in a library that gets loaded > into user programs by default but could be overridden, like the Haskell > prelude. First, if locals are implemented on a separate stack, as a few others here have said they've done for their Forth implementations, how would those definitions even work? They would need to work against the data or parameter stack, not the separate locals stack. Second, why are special tools or generators needed to code the traditional primitives directly in Forth? Third, can't you do the same thing by defining some Forth variables? VARIABLE A VARIABLE B : A@ A @ ; : A! A ! ; : B@ B @ ; : B! B ! ; : 2DUP A! B! B@ A@ B@ A@ ; : DUP A! A@ A@ ; : SWAP A! B! A@ B@ ; : DROP A! ; So, what is the real difference with locals? Is it where the local is stored? e.g., on the stack instead of in memory. If that's the case, a word LOCAL , functioning similar to VARIABLE , but which allocates space on the stack, would be better. Wouldn't it? Rod Pemberton