Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #133621
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: THROW codes and ambiguous conditions |
| Date | 2025-06-08 08:07 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2025Jun8.100714@mips.complang.tuwien.ac.at> (permalink) |
| References | (1 earlier) <2025Jun7.114356@mips.complang.tuwien.ac.at> <8a96d5a50e33757a15ba472d5fa3ae9a171fcff2@i2pn2.org> <87plff4938.fsf@nightsong.com> <nnd$1c16483a$123400ed@7c48093f279e409f> <87ldq33svl.fsf@nightsong.com> |
Paul Rubin <no.email@nospam.invalid> 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/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-05-31 11:10 +1000
Re: THROW codes and ambiguous conditions anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-05-31 06:02 +0000
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-05-31 20:53 +1000
Re: THROW codes and ambiguous conditions sjack@dontemail.me (sjack) - 2025-06-03 20:48 +0000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-05-31 13:53 +0200
Re: THROW codes and ambiguous conditions anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-05-31 16:07 +0000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-01 12:47 +0200
Re: THROW codes and ambiguous conditions anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-06-01 15:15 +0000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-01 19:35 +0200
Re: THROW codes and ambiguous conditions Hans Bezemer <the.beez.speaks@gmail.com> - 2025-06-01 19:44 +0200
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-02 14:58 +1000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-02 12:44 +0200
Re: THROW codes and ambiguous conditions Hans Bezemer <the.beez.speaks@gmail.com> - 2025-06-02 21:20 +0200
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-03 13:23 +1000
Re: THROW codes and ambiguous conditions mhx@iae.nl (mhx) - 2025-06-03 06:04 +0000
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-04 12:03 +1000
Re: THROW codes and ambiguous conditions Hans Bezemer <the.beez.speaks@gmail.com> - 2025-06-06 12:47 +0200
Re: THROW codes and ambiguous conditions anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-06-03 06:10 +0000
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-05 00:44 +1000
Re: THROW codes and ambiguous conditions sean@conman.org - 2025-06-04 19:25 +0000
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-05 16:09 +1000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-05 12:17 +0200
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-06 10:47 +1000
Re: THROW codes and ambiguous conditions sean@conman.org - 2025-06-06 06:15 +0000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-06 13:00 +0200
Re: THROW codes and ambiguous conditions sean@conman.org - 2025-06-06 21:06 +0000
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-07 13:10 +1000
Re: THROW codes and ambiguous conditions sean@conman.org - 2025-06-07 04:26 +0000
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-07 14:42 +1000
Re: THROW codes and ambiguous conditions anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-06-07 09:43 +0000
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-08 00:06 +1000
Re: THROW codes and ambiguous conditions Paul Rubin <no.email@nospam.invalid> - 2025-06-07 12:58 -0700
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-08 01:31 +0200
Re: THROW codes and ambiguous conditions Paul Rubin <no.email@nospam.invalid> - 2025-06-07 18:49 -0700
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-08 13:36 +1000
Re: THROW codes and ambiguous conditions anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-06-08 08:07 +0000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-08 13:34 +0200
Re: THROW codes and ambiguous conditions Paul Rubin <no.email@nospam.invalid> - 2025-06-10 14:11 -0700
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-08 12:16 +1000
Re: THROW codes and ambiguous conditions anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-06-08 07:56 +0000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-08 13:51 +0200
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-09 00:45 +1000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-09 12:49 +0200
Re: THROW codes and ambiguous conditions dxf <dxforth@gmail.com> - 2025-06-09 21:36 +1000
Re: THROW codes and ambiguous conditions zbigniew2011@gmail.com (LIT) - 2025-06-09 12:24 +0000
Re: THROW codes and ambiguous conditions zbigniew2011@gmail.com (LIT) - 2025-06-07 14:41 +0000
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-05 12:12 +0200
Re: THROW codes and ambiguous conditions John <john@somewhere> - 2025-06-03 03:43 -0500
Re: THROW codes and ambiguous conditions albert@spenarnc.xs4all.nl - 2025-06-03 12:30 +0200
Re: THROW codes and ambiguous conditions Hans Bezemer <the.beez.speaks@gmail.com> - 2025-06-03 15:10 +0200
csiph-web