Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #57450
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: string-stack.4th |
| Date | 2017-04-16 15:51 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2017Apr16.175138@mips.complang.tuwien.ac.at> (permalink) |
| References | (4 earlier) <5a9dd21c-5b85-45be-bbee-c444cb8243d8@googlegroups.com> <c734b1d9-976c-4d68-897a-d464509b0536@googlegroups.com> <b0de7690-6977-4513-9804-d3782771a64e@googlegroups.com> <ee44fdd6-18dc-4076-b4b6-b2c4b8765ed3@googlegroups.com> <xn0kosx1g3k40me003@nntp.aioe.org> |
"Rudy Velthuis" <newsgroups@rvelthuis.de> writes:
>I don't really understand why currently, in Forth, an address/length
>combination is used so often. The length should, when possible, be
>stored as part of the string data, just like old-fashioned (byte)
>counted strings.
Why?
Concerning reasons: From
<http://www.complang.tuwien.ac.at/anton/euroforth/ef13/papers/ertl-strings.pdf>:
|The favoured string representation in standard
|Forth is c-addr u. It allows representing strings
|of any length with any content, and you can pro-
|duce arbitrary substrings without needing to copy
|the string to a new buffer. The disadvantage of
|this representation is that it takes two cells on the
|stack, and dealing with several strings at once can
|therefore be cumbersome.
|
| The other common string representation in stan-
|dard Forth is the counted string: The on-stack rep-
|resentation is the address of the count byte; the
|count byte is followed by the characters of the
|string. The advantage of this representation is that
|it needs only one cell on the stack. But it can only
|represent strings with up to 255 chars, and any
|substring operation needs to create a new string
|buffer. Converting from counted to c-addr u is
|easy (count), but the other direction is cumber-
|some. Some people have suggested using cell counts
|instead of byte counts to get rid of the length limi-
|tation.
> The address-length pair only make sense if the string
>data is read directly from some kind of buffer and the buffer should
>not/cannot be modified. This only makes sense for transient data, e.g.
>when parsing a word or string of which the string data that can easily
>be discarded after use (e.g. when interpreting or compiling and you
>only parse to, er, find out what to do next).
Much of my strings usage is like that. A good reason to use c-addr u.
Do you really want to copy a substring to a separate buffer (and where
do you allocate that?) before you can, e.g., write it to a file? I
don't.
- 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: http://www.forth200x.org/forth200x.html
EuroForth 2016: http://www.euroforth.org/ef16/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-15 16:54 -0700
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-15 19:55 -0700
Re: string-stack.4th Julian Fondren <julian.fondren@gmail.com> - 2017-04-15 20:08 -0700
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-16 13:50 +0000
Re: string-stack.4th anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-16 15:51 +0000
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-16 22:16 +0000
Re: string-stack.4th anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-17 12:04 +0000
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-17 13:11 -0700
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-17 23:18 +0000
Re: string-stack.4th albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-18 01:49 +0200
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-19 23:03 +0000
Re: string-stack.4th "Elizabeth D. Rather" <erather@forth.com> - 2017-04-19 13:19 -1000
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-20 00:15 +0000
Re: string-stack.4th "Elizabeth D. Rather" <erather@forth.com> - 2017-04-19 14:34 -1000
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-20 17:16 +0000
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-20 15:08 -0700
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-20 00:16 +0000
Re: string-stack.4th albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-20 21:10 +0200
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-21 09:59 +0000
Re: string-stack.4th albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-20 20:50 +0200
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-17 19:47 -0700
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-19 23:08 +0000
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-18 00:10 -0700
Re: string-stack.4th Alex <alex@rivadpm.com> - 2017-04-18 13:48 +0100
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-18 09:15 -0700
Re: string-stack.4th Alex <alex@rivadpm.com> - 2017-04-18 18:23 +0100
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-17 23:07 +0000
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-18 09:09 -0700
Re: string-stack.4th lehs <skydda.barnen@gmail.com> - 2017-04-18 10:27 -0700
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-16 19:26 -0700
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-17 23:13 +0000
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-23 12:39 -0700
Re: string-stack.4th Michael Barry <barrym95838@yahoo.com> - 2017-04-23 22:25 -0700
Re: string-stack.4th foxaudioresearch@gmail.com - 2017-04-24 14:06 -0700
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-29 03:19 +0000
Re: string-stack.4th Ron Aaron <rambamist@gmail.com> - 2017-04-24 08:35 +0300
Re: string-stack.4th Paul Rubin <no.email@nospam.invalid> - 2017-04-23 23:51 -0700
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-24 00:10 -0700
Re: string-stack.4th Ron Aaron <rambamist@gmail.com> - 2017-04-24 10:11 +0300
Re: string-stack.4th Lars Brinkhoff <lars.spam@nocrew.org> - 2017-04-24 09:27 +0200
Re: string-stack.4th Paul Rubin <no.email@nospam.invalid> - 2017-04-24 01:14 -0700
Re: string-stack.4th Alex <alex@rivadpm.com> - 2017-04-24 14:38 +0100
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-29 03:18 +0000
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-29 03:27 +0000
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-28 22:13 -0700
Re: string-stack.4th Alex <alex@rivadpm.com> - 2017-04-29 09:41 +0100
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-29 07:05 -0700
Re: string-stack.4th "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-29 11:43 +0000
Re: string-stack.4th hughaguilar96@gmail.com - 2017-04-15 21:15 -0700
csiph-web