Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Alexander Skobelev Newsgroups: comp.lang.forth Subject: Re: FORTH on the Advanced Placement Computer Science ! Date: Mon, 12 Jan 2015 09:05:56 +0300 Organization: A noiseless patient Spider Lines: 113 Message-ID: References: <7xbnmquimp.fsf@ruckus.brouhaha.com> <3d03e403-7181-4ab3-8a2f-a23d0c4843f7@googlegroups.com> <87y4pt4qkl.fsf@jester.gateway.sonic.net> <2014Dec27.111715@mips.complang.tuwien.ac.at> <878uhs4zxk.fsf@jester.gateway.sonic.net> <871tnd9dg0.fsf@jester.gateway.pace.com> <87387q5hi8.fsf@jester.gateway.sonic.net> <43c6114f-8d41-4005-9131-fe93ec3d3696@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="b120e5c8b4f216b4cd7561d02d477618"; logging-data="1020"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pTcuz9bc/NTAFQD4O8NVn" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (darwin) Cancel-Lock: sha1:xe0kMBhD+2G51knwLcfyu3Pv61c= sha1:Ec09PmgjPwKbFamvFMafAlNawmQ= Xref: csiph.com comp.lang.forth:35738 Coos Haak writes: > Op Sun, 11 Jan 2015 16:56:51 +0300 schreef Alexander Skobelev: > >> "Elizabeth D. Rather" writes: >> >>> On 1/10/15 1:35 AM, Alexander Skobelev wrote: >>>> "Elizabeth D. Rather" writes: >>>> >>>>> On 1/9/15 3:25 AM, Alexander Skobelev wrote: >>>>>> "Elizabeth D. Rather" writes: >>>>>> >>>>>>> On 1/8/15 7:04 PM, Alexander Skobelev wrote: >>>>>>>> hughaguilar96@gmail.com writes: >>>>>>>> >>>>>>>>> The ANS-Forth standard doesn't support the use of C" and S" in >>>>>>>>> interpretive mode, and SwiftForth and Gforth both fail at this. I >>>>>>>>> fixed the problem in my novice package --- this is really necessary to >>>>>>>>> interactively debug functions that take strings as arguments. >>>>>>>>> >>>>>>>> >>>>>>>> Perhaps you have meant C" only, as S" in interpretive mode seems to be >>>>>>>> Gforth as well as ANS-Forth in FILE word set (see 11.6.1.2165). >>>>>>> >>>>>>> C" is actually not used very much nowadays, AFAIK. It was retained in >>>>>>> Forth94 because at the time some people used it, but I think counted >>>>>>> strings are used much less nowadays. >>>>>> >>>>>> I think they still can be useful for storing short strings in structure >>>>>> fields with a fixed width. >>>>>> >>>>>> Something like in this: >>>>>> 0 >>>>>> 22 CHARS +FIELD person.name >>>>>> ... >>>>>> CONSTANT Person >>>>>> >>>>>> , – where the person.name field is supposed to store a counted string of >>>>>> no more than 21 characters length. >>>>> >>>>> Oh, counted strings are wonderful! IMO they are the preferred way to >>>>> store strings internally, for many reasons. The vast majority of >>>>> internal strings work with an 8-bit count. But for some years we have >>>>> been gravitating toward using addr-cnt pairs for passing references to >>>>> strings on the stack. In our implementation, S" stores its string as a >>>>> counted string, likewise names and other strings, but we pass addr-cnt >>>>> on the stack. That is why C" (which passes the address of a counted >>>>> string) is not often used and there was no pressure to make an >>>>> interpretive version. >>>>> >>>> >>>> This is interesting. But that means that either your implementation the >>>> S" strings limited to 256 characters or you should use some tricks in >>>> the counted strings to store more characters there. >>> >>> I don't think S" is the right mechanism to handle strings longer than >>> 256 bytes. Very few applications actually require such long strings, >>> particularly in definitions. The few string-intensive applications >>> I've been involved with have developed application-specific data >>> structures for the long strings. >> >> Perhaps it's so. But how somebody has told about multiple inheritance: it >> is rarely needed, but sometimes it is really needed. I think this is the >> same case here. >> >> "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod >> tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim >> veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea >> commodo consequat. Duis aute irure dolor in reprehenderit in voluptate >> velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint >> occaecat cupidatat non proident, sunt in culpa qui officia deserunt >> mollit anim id est laborum." >> >> What is the right way to put this text in a program on Forth? > > Put the string (including the quotes) in a file and load the file with > ciforth: > > $ wina \ this is cygwin, lina under linux works the same. > > 80386 ciforth 5.1 > "long.frt" INCLUDED > OK > TYPE > Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod > tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim > veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea > commodo consequat. Duis aute irure dolor in reprehenderit in voluptate > velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint > occaecat cupidatat non proident, sunt in culpa qui officia deserunt > mollit anim id est laborum. OK > It looks like ciforth supports strings like "..." with length more than 256 characters. And you don't need read them from separate file: iMac:~ sasha$ /usr/local/xina/xina 80386 ciforth beta-5.123 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." OK . . 445 36872 OK Aha, I see you should put the string into the file if it contains line breaks inside. > -- > Coos > > CHForth, 16 bit DOS applications > http://home.hccnet.nl/j.j.haak/forth.html