Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #35711
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? |
| Date | 2015-01-11 12:02 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2015Jan11.130239@mips.complang.tuwien.ac.at> (permalink) |
| References | <15768286-9591-4ea9-a5f9-87ce02244f4a@googlegroups.com> |
Michael Barry <barrym95838@yahoo.com> writes:
>I have a hypothetical machine that doesn't address bytes, only 32-
> bit words. Chars, cells, addresses, single-precision integers and
> single-precision floats are all 32-bits wide. In a world where
> UTF-32 was the standard way to encode a character, this would be
> perfect, and is how my default method of handling strings in Forth
> would work.
>
>I don't like the idea of excluding a more efficient way of handling
> UTF-16 and UTF-8 strings by packing two or four chars in each word,
> but there are some questions I have about how much complexity this
> would add to an otherwise very simple and clean design.
The main question is: If you want to handle so much string data that
32-bit chars are too inefficient, why do you choose a cell-addressed
machine? Otherwise using 32-bit chars is the way to go IMO.
If you really want to put more than one char in an address unit, I
think the way to go is to look at what operations you want to do with
the strings, and have special words for doing these operations with
your special string representation.
>My first idea is to have two attribute bits in the highest-order
> end of the count cell at the beginning of the string. Zeros there
> would indicate that the following string is UTF-32, limiting it
> to a length of about 10^9 chars. Other two-bit values could
> indicate alternate encodings. Exactly how the remaining 30 bits
> in the count cell would do this is where I need some help.
>
>I don't have sufficient knowledge of the advanced features of Forth
> to know whether or not it is feasible to have all the words that
> create, move, compare, compile and manipulate strings be able to
> determine the encoding and act appropriately, since frequent
> packing and unpacking would be wasteful.
For normal Forth strings represented by (addr u) even simple address
and length arithmetics like
( addr1 u1 ) swap char+ swap 2 - ( addr2 u2 )
has to work, and that would not work with your representation. Even
for counted strings, you can convert them to addr u strings with
dup c@ swap char+
and cannot work with your representation, either.
Many people are not satisfied by the string handling provided in the
standard, and have developed string packages. Some (probably
especially the ones having a string stack) might have an interface
that is abstract enough that it can be used with your representation.
I have not looked closely enough at them to point you to a particular
one.
- 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 2014: http://www.euroforth.org/ef14/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Packed strings in Forth ... any thoughts, advice, or links to prior art? Michael Barry <barrym95838@yahoo.com> - 2015-01-11 00:42 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? stephen@mpeforth.com (Stephen Pelc) - 2015-01-11 12:03 +0000
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-01-11 12:02 +0000
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Michael Barry <barrym95838@yahoo.com> - 2015-01-11 11:29 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Bernd Paysan <bernd.paysan@gmx.de> - 2015-01-11 22:24 +0100
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-01-12 10:10 +0000
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-01-12 10:12 +0000
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-01-12 11:17 +0000
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Michael Barry <barrym95838@yahoo.com> - 2015-01-12 19:13 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? hughaguilar96@gmail.com - 2015-01-11 14:38 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Michael Barry <barrym95838@yahoo.com> - 2015-01-11 17:09 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? "Elizabeth D. Rather" <erather@forth.com> - 2015-01-11 17:18 -1000
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Michael Barry <barrym95838@yahoo.com> - 2015-01-11 19:48 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? hughaguilar96@gmail.com - 2015-01-12 17:59 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Michael Barry <barrym95838@yahoo.com> - 2015-01-12 19:04 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? hughaguilar96@gmail.com - 2015-01-12 19:52 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Michael Barry <barrym95838@yahoo.com> - 2015-01-12 20:28 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? hughaguilar96@gmail.com - 2015-01-13 19:42 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Alexander Skobelev <al.skobelev@gmail.com> - 2015-01-13 08:38 +0300
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Alexander Skobelev <al.skobelev@gmail.com> - 2015-01-13 08:43 +0300
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? hughaguilar96@gmail.com - 2015-01-13 19:27 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? "Alex McDonald" <blog@rivadpm.com> - 2015-01-12 10:03 +0000
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? hughaguilar96@gmail.com - 2015-01-12 18:11 -0800
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? "Alex McDonald" <blog@rivadpm.com> - 2015-01-13 09:56 +0000
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Bernd Paysan <bernd.paysan@gmx.de> - 2015-01-14 03:07 +0100
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-01-14 11:27 +0000
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Bernd Paysan <bernd.paysan@gmx.de> - 2015-01-15 18:09 +0100
Re: Packed strings in Forth ... any thoughts, advice, or links to prior art? Ilya Tarasov <ilya74.tarasov@gmail.com> - 2015-01-15 06:42 -0800
csiph-web