On Monday, April 24, 2017 at 2:11:14 AM UTC-7, The Beez wrote:
> On Saturday, April 22, 2017 at 3:19:39 AM UTC+2,
hughag...@gmail.com wrote:
> > What if you have more than two strings?
> You use a circular buffer. That's what 4tH does. 4tH's string constants are kept in a separate segment, which can't be directly accessed by any of 4tH's words. In order to maintain compatibility with Forth, these strings are copied to the system buffer within 4tH's (user accessible) character segment - and the address they get there is the one which is returned. E.g. S" Hello world".
>
> Sure, at one point in time those strings are overwritten, but that rarely poses any problems if you follow the rule "save clobbered strings somewhere else".
I have had <CSTR in the novice-package since 2010. My <CSTR is loosely based on the circular buffer of strings that UR/Forth provided --- that worked pretty well. All in all, UR/Forth was the best Forth system of the 1990s! Even today, UR/Forth is more convenient for writing programs than VFX, but UR/Forth being only for MS-DOS makes it obsolete. Recently Raimond Dragomir upgraded my <CSTR, and this upgrade will be put in the next novice-package release.
My STRING-STACK.4TH is significantly better. That COW (copy-on-write) idea works quite well for boosting speed. Also, it uses less memory because it only allocates memory for strings in use. Also, it allows for strings of any size, not limited to 256 chars. Also, it provides a convenient way of accessing multiple strings (the stack-juggler words) so it is not necessary to hold the string addresses in variables as with <CSTR. All in all, STRING-STACK.4TH is very good --- I use <CSTR for a couple of words in STRING-STACK.4TH --- it does concatenation more efficiently, so it is useful for building a string by appending.
> The consequence is though that this area called "PAD" may only be altered by the application programmer at his own risk. If you need a "user-PAD", define one yourself.
PAD is absolutely worthless. Putting PAD in the standard makes the Forth community look stupid.