Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Alexander Skobelev Newsgroups: comp.lang.forth Subject: Re: FORTH LITE TUTORIAL based on MPE VFX Date: Thu, 26 Jun 2014 11:30:05 +0400 Organization: A noiseless patient Spider Lines: 24 Message-ID: References: <2d2eba75-5d44-422a-8a3f-751702d8cea6@googlegroups.com> <45f5f8f9-e2c0-42f1-8640-8108c55d397f@googlegroups.com> <1ad192b0-6c5b-462c-8d19-cad563dbf974@googlegroups.com> <557e2d7a-6003-42af-803b-5d21a00315bd@googlegroups.com> <87ceaa31-134f-4503-8a49-e07b4061b301@googlegroups.com> <29b02601-d43c-4f76-8f3a-02bb4855a09a@googlegroups.com> <31f28699-46bc-4f5b-a1f2-565d663dfd3e@googlegroups.com> <2cb5ef69-0e06-4a07-8594-5f65b3d2a714@googlegroups.com> <4e5d1063-b6f1-4cd8-ae53-be0435e372ee@googlegroups.com> <96e20bcc-9f13-4212-9959-6fa4765b40c1@googlegroups.com> <243713a6-b8b2-4053-bb59-6249ebf6b7f5@googlegroups.com> <39b481fe-3c92-44bc-aee7-b344fa9d523d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="0bbd6ff8dce8d563070daea2d73d76f2"; logging-data="7103"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IlNUd9szhXURrWamvYB47" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (darwin) Cancel-Lock: sha1:UJ2XXRt5WFrdBAB3Whh7i1arNUk= sha1:E22jY0ctRAD7+z+/wqZzJqUckB4= Xref: csiph.com comp.lang.forth:31866 Ron Aaron writes: > On 06/26/2014 09:45 AM, Alexander Skobelev wrote: > >> I suppose that can be done by using a count of variable size. For >> example, we can store the length of count in 2 high bits of it: >> >> 00 - count is 1 byte and maximum length is 2^6-1 = 63 >> 01 - count is 2 bytes and maximum length is 2^6 * 256 + 255 = 16383 > ... > > I had considered doing that in Reva, but figured the extra complexity of > decoding a count byte did not justify the small space savings per > string. Instead I went with 'short' and 'long' strings. My latest > efforts are all 'long' strings... Well I'd rather also leave one bit to mark a count to be one byte's length or in a cell size. In this case I would have 127 bytes or whatever limited by cell size. And decoding is seems not to be very complex: you always read the whole cell and (on big-endian architecture) just shift the count to get one byte value if the flag is not set of just mask the high byte if it's set . For little endian architecture it seems better to store the flag in lower bit in the first byte of counter. Then always rshift the count by 1.