Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: Epic Fail Date: Sun, 13 Apr 2014 20:33:21 -0400 Organization: Aioe.org NNTP Server Lines: 48 Message-ID: References: <2014Apr7.192923@mips.complang.tuwien.ac.at> <19597f37-fa23-478f-9a5f-b2aa66e89ae4@googlegroups.com> <2014Apr8.175427@mips.complang.tuwien.ac.at> <2014Apr9.181655@mips.complang.tuwien.ac.at> <64idnem648RzN9jOnZ2dnUVZ8iWdnZ2d@supernews.com> <4cde73fc-f677-4377-ac78-7f81ee13ae65@googlegroups.com> NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; 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:29622 On Sun, 13 Apr 2014 13:25:32 -0400, Andrew Haley wrote: > Rod Pemberton wrote: >> But, I'm coming from the C perspective that [locals] should be >> treated like [an unitialized global variable] and cleared. Of course, >> C doesn't automatically clear auto or procedure local variables, >> which requires the programmer to do so. So, it's entirely possible >> that Forth should treat them the way Anton did too. > > Hold on, are you saying that you think that locals should be zeroed, [RP's posted correction inserted above] Yes. It's a safety issue. Although they're technically locals, they also seem somewhat similar to globals in C which are cleared. > but C doesn't do so, Yes. C doesn't clear locals. But, locals in C are typically initialized at some point by the programmer, and usually safely. I.e., it's a slight potential safety issue to not clear locals in C since they can be used without being initialized. However, that's generally infrequent. C compilers are generally pretty good at warning about unused and unitialized procedure locals too. I.e., there is a safety check in place on their use: the C compiler. > therefore not zeroing Forth locals should be okay? s/should/could/ s/okay/acceptable in Forth/ If Forth programmers typically init the locals in a safe manner, then, obviously, clearing them is not needed at all. But, ISTM that it makes more sense to treat them as globals and clear. Why? How are you going to require they're initialized prior to usage? ... If, as I suspect, that's not easy to implement in Forth or across a variety of Forths, then it's far better to clear. Do any Forths emit warnings for use of unitialized locals? ... If, as I suspect, none do, then it's far better to clear. Rod Pemberton