Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.lang.forth Subject: Re: THROW codes and ambiguous conditions Date: Sun, 08 Jun 2025 08:07:14 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 39 Message-ID: <2025Jun8.100714@mips.complang.tuwien.ac.at> References: <2025Jun7.114356@mips.complang.tuwien.ac.at> <8a96d5a50e33757a15ba472d5fa3ae9a171fcff2@i2pn2.org> <87plff4938.fsf@nightsong.com> <87ldq33svl.fsf@nightsong.com> Injection-Date: Sun, 08 Jun 2025 10:40:02 +0200 (CEST) Injection-Info: dont-email.me; posting-host="3674094924e29eae558a42a1233a1d7a"; logging-data="3942784"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7Nd9PmwuTDNG2CPyNLroB" Cancel-Lock: sha1:mDKWnW3juHrmKkLbgk6o1AbcZy8= X-newsreader: xrn 10.11 Paul Rubin writes: >I wonder if there's a standard or well known way to capture the output >of . and related words, like redirecting the input stream. In some systems TYPE and EMIT are a deferred words. So I can do : no-output-execute ( ... xt -- ... ) action-of type action-of emit 2>r ['] 2drop is type ['] drop is emit catch 2r> is emit is type throw ; .." |" 5 ' . no-output-execute ." |" This works in Gforth and in VFX64. SwiftForth has a system (personalities) for vectoring a number of I/O words, including TYPE. So the code above does not work in SwiftForth, but you can define a personality to achieve the same thing. LOCATE SIMPLE-BUFFERING in SwiftForth to see how a personality is defined. Gforth actually gives you both worlds: TYPE is a defer-flavoured field in a method table accessed through a user variable. So you can define such a table (with OUTPUT:) and use it for changing the output, or you can do the quick-and-dirty approach of revectoring the individual words shown above. However, if you actually want to have the result in a string, you also need to manage a buffer such that consecutive calls to TYPE and EMIT are concatenated. In Gforth, >STRING-EXECUTE does all that for you. You only have to FREE the buffer once you are done with it. - anton -- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html New standard: https://forth-standard.org/ EuroForth 2023 proceedings: http://www.euroforth.org/ef23/papers/ EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/