[retroforth] Re: factoring request

  • From: Charles Childers <crc@xxxxxxxxxxxxxx>
  • To: retroforth@xxxxxxxxxxxxx
  • Date: Tue, 26 Oct 2004 14:41:08 -0400

>>>>What's so bad about hyphens? We already have a couple of words (zt-make 
>>>>and zt-free) with hyphens.
>>>>   
>>>>
>>>>        
>>>>
>>>are those words? :-) scnr
>>> 
>>>
>>>      
>>>
>>Yes.
>>    
>>
>
>btw: we were only making fun with creat and reate ...
>  
>
I know :-)

>>What does SwiftForth call the words to turn a counted string into a zero 
>>terminated one, and to free up the memory used?
>>    
>>
>
>hmmm... good question. In my Windows apps I usually start out
>with zero terminated strings and then use zcount ( z -- a n ).
>Re memory: SwiftForth usually uses dynamic allocation for
>temporary string storage, so the usual FREE ( a -- ior ) suffices.
>  
>
To create a zero terminated string in RetroForth you do:

" a string" zt-make

zt-make ( a c -- a c ) takes a counted string, and returns a zero 
terminated one (allocated at HERE) with a length of C
zt-free ( c -- ) frees up the space allocated for the zero terminated string

I don't have any dynamic memory allocation in RetroForth, but the 
zt-make/zt-free solution works quite well.

--
Charles

Other related posts: