Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!MITCH.ENG.SUN.COM!wmb From: wmb@MITCH.ENG.SUN.COM Newsgroups: comp.lang.forth Subject: Re: Data Structures Message-ID: <9009220053.AA13718@ucbvax.Berkeley.EDU> Date: 21 Sep 90 20:17:21 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: wmb%MITCH.ENG.SUN.COM@SCFVM.GSFC.NASA.GOV Organization: The Internet Lines: 22 > How do I get "adr len" on the stack? The operation is defined for strings > defined with " , but what about strings in memory? I can only get the > address of a string buffer defined with CREATE, for example. I must use > COUNT, or perhaps STRLEN for a null terminated string, to get the length. > I do not want to have to declare a seperate VARIABLE for the length of > each string buffer I use. : string: \ name ( max-size -- ) create 0 , allot does> ( pfa -- adr len ) dup cell+ swap @ ; The operators for manipulating strings should be as general as possible, and independent of how those strings happen to be encoded when stored in memory. One might reasonably choose different memory encodings for different applications, but the stack representation should always be the same, so that we could build upon a single set of string operators, rather than having the piecemeal set of operators, split among several different string representations, that we have now. Mitch Bradley, wmb@Eng.Sun.COM