X-Received: by 10.129.85.23 with SMTP id j23mr1176214ywb.55.1494783812800; Sun, 14 May 2017 10:43:32 -0700 (PDT) X-Received: by 10.157.31.68 with SMTP id x4mr43926otx.19.1494783812758; Sun, 14 May 2017 10:43:32 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!l39no897119qtb.0!news-out.google.com!m134ni425itb.0!nntp.google.com!c26no1456645itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.forth Date: Sun, 14 May 2017 10:43:32 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=5.13.207.232; posting-account=zi_V9AoAAABIeBwv9mCUarc9fdBq4z4E NNTP-Posting-Host: 5.13.207.232 References: <13e6c647-fd9a-4d77-89e3-2cc977f3bd5b@googlegroups.com> <1cca60ee-6f98-443d-8466-d7efbea8724f@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Would ?EXIT work in all ANS-Forth systems? From: humptydumpty Injection-Date: Sun, 14 May 2017 17:43:32 +0000 Content-Type: text/plain; charset="UTF-8" Xref: csiph.com comp.lang.forth:59223 On Sunday, May 14, 2017 at 5:21:50 PM UTC+3, Andrew Haley wrote: > HAA wrote: > > > In the days when "return stack" meant return stack and threaded code > > was the norm R> DROP is what you would use. ANS precludes this, > > forcing programmers to adopt inefficient solutions. > > No. That is not how it happened. ANS did not preclude return stack > hackery because it wasn't portable anyway. Before the ANS process > began, the number of return stack items pushed by a colon definition > wasn't always 1. And maybe you'd even be using a different stack for > return addresses. This is mind boggling! Was that Forth? What is the percentage of such implementations from all Forth implementations? > So maybe the R> DROP trick would work, maybe not. But this is not a trick. Is applying knowledge that on return-stack is the address of continuation(partial) of current definition caller. > > In that sense, the situation is not any different post-ANS: if you > want to depend on a colon definition pushing one item onto the return > stack you can still assume that. ANS did not cause this trick to stop > working: it was descriptive rather than prescriptive. > > > Here's an example of a routine that deserves to be as efficient as > > it looks. > > > > : ?# ( ud -- ud ) # 2dup d0= if r> drop then ; > > > > : #,S ( ud -- 0 0 ) begin ?# ?# ?# [char] , hold again ; > > I hope that wouldn't pass review. This is a very nice factored code! What matter is idea behind code. User will modify '?#' definition accordingly with used Forth implementation, if necessary, or choose another Forth implementation. > > Andrew. -- Have a nice day, hum9