If my stack contains the string "Apple for the teacher", and I want to
tokenize the second word "for", and find the numerical placement value of
where "for" starts - how efficient/effective is Forth at doing this? How
does this compare to what is going on in a variable based language?
--
Richard S. Westmoreland
http://www.antisource.com
> If my stack contains the string "Apple for the teacher", and I want to
> tokenize the second word "for", and find the numerical placement value of
> where "for" starts - how efficient/effective is Forth at doing this? How
> does this compare to what is going on in a variable based language?
I guess even a native code Forth is not much more efficient at this than
Java!
But ... you're asking the wrong question. (You know I would say that,
wouldn't you :-) In Spectrum BASIC (for the ZX80) and HP Basic (for 68000)
I used strings almost for everything, just because they were there and the
tool I actually needed was not. In Forth I cannot remember ever using the
search-in-string function (although I wrote one, of course).
Describe a real-world problem that you think needs strings, and we'll
(probably) show you a way to do it that does not use them (except maybe
for PLACE PLACE+ $+ , and of course WORD PARSE EVALUATE etc.)
-marcel
Boyer-Moore algorithm. Fairly easy to write in Forth. Of course it
might be overkill for anything but mammoth strings.
--
Julian V. Noble
Professor Emeritus of Physics
j...@lessspamformother.virginia.edu
^^^^^^^^^^^^^^^^^^
http://galileo.phys.virginia.edu/~jvn/
"For there was never yet philosopher that could endure the
toothache patiently."
-- Wm. Shakespeare, Much Ado about Nothing. Act v. Sc. 1.
Look:
s" Apple for the teacher" s" for" search cr . cr type
--> results in
-1
for the teacher ok
What you asked for is a bit more complicated:
s" Apple for the teacher" 2dup s" for" search drop nip - cr . drop
--> results in
6
This is where "for" starts.
> How
> does this compare to what is going on in a variable based language?
I don't do strings in C (they are a pain!), but in Java it is ok.
Best regards,
Daniel
It is such a pity that Gordon Charlton gave up partaking in this newsgroup.
He produced a very nice string matcher lexicon called FOSM. You may find it
around on the web somewhere (maybe the uk site, which is linked from my
Forth page, but I haven't looked there lateley).
--
********************************************************************
Paul E. Bennett ....................<email://peb@a...>
Forth based HIDECS Consultancy .....<http://www.amleth.demon.co.uk/>
Mob: +44 (0)7811-639972 .........NOW AVAILABLE:- HIDECS COURSE......
Tel: +44 (0)1235-811095 .... see http://www.feabhas.com for details.
Going Forth Safely ..... EBA. www.electric-boat-association.org.uk..
********************************************************************
Paul E. Bennett schrieb:
> Richard S. Westmoreland wrote:
>
>
>>Beginning to cover a lot of string handling in my Java class. And I'm
>>always trying to relate what I learn to how Forth would accomplish it.
>>
>>If my stack contains the string "Apple for the teacher", and I want to
>>tokenize the second word "for", and find the numerical placement value of
>>where "for" starts - how efficient/effective is Forth at doing this? How
>>does this compare to what is going on in a variable based language?
>>
>>--
>>Richard S. Westmoreland
>>http://www.antisource.com
>
>
> It is such a pity that Gordon Charlton gave up partaking in this newsgroup.
> He produced a very nice string matcher lexicon called FOSM. You may find it
> around on the web somewhere (maybe the uk site, which is linked from my
> Forth page, but I haven't looked there lateley).
ftp://ftp.taygeta.com/pub/Forth/Applications/fosm1v1.zip
>
--
linux + assembly + forth >hp -a- lxhp -:- in-berlin -:- de<
www.lxhp.in-berlin.de/index-lx.html; linux-a...@mlists.in-berlin.de
> Beginning to cover a lot of string handling in my Java class. And I'm
> always trying to relate what I learn to how Forth would accomplish it.
>
> If my stack contains the string "Apple for the teacher", and I want to
> tokenize the second word "for", and find the numerical placement value of
> where "for" starts - how efficient/effective is Forth at doing this? How
> does this compare to what is going on in a variable based language?
With object extensions in Forth we can have a rich, full-featured, and
very easy to use set of string tools. This example uses existing
methods from the standard Mops string library.
\ *** begin code
string s \ instantiate an object of class string, named s
ok
" Apple for the teacher" put: s \ put some text in the object
ok
" for" search: s . \ no explanation needed
-1 ok \ the search retuned "true", means it was successful
lim: s . \ limit marks the beginning of the found substring
6 ok
" , polished and ready to eat." add: s \ no explanation needed
ok
all: s type
Apple for the teacher, polished and ready to eat. ok
\ *** end code
The string is stored in the heap and will grow or shrink dynamically as
needed. Pretty simple stuff.
Effective? I think so.
Efficient? Can't answer that easily. I suppose it depends on what you
need to do. It took me less than a minute to type and execute the
above. That seemed efficient in terms of programmer's time and effort.
Regards,
-Doug
> string s \ instantiate an object of class string, named s
> ok
> " Apple for the teacher" put: s \ put some text in the object
> ok
> " for" search: s . \ no explanation needed
> -1 ok \ the search retuned "true", means it was successful
> lim: s . \ limit marks the beginning of the found substring
> 6 ok
> " , polished and ready to eat." add: s \ no explanation needed
> ok
> all: s type
> Apple for the teacher, polished and ready to eat. ok
FORTH> needs -strings
Creating --- String Package Version 2.01 ---
FORTH> string s 256 new s ok
FORTH> S" Apple for the teacher" TO s ok
FORTH> S" for" index s . 6 ok
FORTH> S" , polished and ready to eat." +TO s ok
FORTH> s cr type
Apple for the teacher, polished and ready to eat. ok
FORTH>
Unless, like me, you implement a string stack. Then the string really
is on the stack.
--
-GJC [MS Windows SDK MVP]
-Software Consultant (Embedded systems and Real Time Controls)
- http://www.mvps.org/ArcaneIncantations/consulting.htm
-gcha...@mvps.org
> > Richard, As Marcel so capably demonstrates, sophisticated string
> > handling in Forth can be done many ways and not just with objects (as
> > I may have implied, inadvertently). You speak of the stack as
> > "containing" the string. This is really not quite the case. The
> > string itself, while it *could* be stored entirely on the stack (no
> > one I know would do such a thing), is stored in normal memory just
> > like most other programming languages. The stack will typically
> > contain the address and length of the string.
>
> Unless, like me, you implement a string stack. Then the string really
> is on the stack.
Thank you Gary. I stand corrected. "sophisticated string handling in
Forth can be done many ways" - More ways than I had imagined!
Regards,
-Doug
One method, very stack consuming and silly is this:
: PUSH ( c-addr u -- [char].. u )
DUP >R DUP
IF 1- OVER +
DO I C@ -1 +LOOP
ELSE 2DROP THEN
R>
;
: APPEND-CHAR ( char c-addr -- )
DUP >R COUNT + C! 1 R> C+!
;
: POP ( [char].. u -- c-addr u )
0 PAD C! 0
?DO PAD APPEND-CHAR
LOOP
PAD COUNT
;
Use like this:
S" Hello" PUSH \ Now the string is really on the stack ;-)
POP \ The string descriptors ( c-addr and u ) are on the stack
TYPE
--
Coos
> One method, very stack consuming and silly is this:
>
> : PUSH ( c-addr u -- [char].. u )
> DUP >R DUP
> IF 1- OVER +
> DO I C@ -1 +LOOP
> ELSE 2DROP THEN
> R>
> ;
>
> : APPEND-CHAR ( char c-addr -- )
> DUP >R COUNT + C! 1 R> C+!
> ;
>
> : POP ( [char].. u -- c-addr u )
> 0 PAD C! 0
> ?DO PAD APPEND-CHAR
> LOOP
> PAD COUNT
> ;
>
> Use like this:
>
> S" Hello" PUSH \ Now the string is really on the stack ;-)
> POP \ The string descriptors ( c-addr and u ) are on the stack
> TYPE
There's one in every crowd. ;-)
This reminds me of The Apple Macintosh Book by Cary Lu where he says:
" (Forth) programming essentially consists of keeping track of where
you are on the stack; since the stack can be many thousands of
variables deep, this can get complicated."
Regards,
-Doug
Or using the Lisp-like lists in Forth package, we have
the following example (under kForth):
include ans-words \ only for kForth
include strings
include lists
nil ptr s
'( Apple for the teacher ) to s
ok
quote for s member print
( for the teacher ) ok
ok
s '( , polished and ready to eat. ) append print
( Apple for the teacher , polished and ready to eat. ) ok
--
The lists.4th code is available from the kForth examples page
at http://ccreweb.org/software/kforth/kforth4.html
KM
1 cells constant sp
2 cells constant s0
: s@ @ @ count ; ( s -- a n)
: s> dup @ tuck cell- swap ! @ count ; ( s -- a n)
\ initialize the stack
: string-stack ( a n --)
chars over + over over over ( a s0 a s0 a)
sp + ! s0 + tuck ! swap ! ( --)
;
\ put a string on the stack
: >s ( a n s --)
over 1+ chars over sp + @ swap - ( a n s p)
over @ cell+ dup >r over > ( a n s p f)
if drop 2dup s0 + @ swap 1+ chars - then
>r -rot r@ place r@ over ( s p s)
sp + ! r> r@ ! r> swap ! ( --)
;
This is code from the upcoming release of 4tH V3.4e
I haven't tested it yet on any ANS-Forth yet, but I guess it works. It
features an application string stack (you can have several independant
ones) which is an ordinary stack along with a circular buffer. Much
more efficient than dumping strings onto the stack character by
character. Use it like this:
align \ just in case
/mystack constant 4096 \ any size you like
create mystack /mystack allot \ reserve space
mystack /mystack string-stack
s" This is the end" mystack >s \ put string on stack
mystack s@ type cr \ fetch top of string stack
s" Beautiful friend" mystack >s \ dump another one
mystack s> mystack s> \ pop both from stack
s" My only friend" mystack >s \ push another one
2swap mystack >s mystack >s \ swap strings and push 'em
mystack s> mystack s> mystack s> \ clear stack
type type type cr \ now display everything
It's true, no checks for popping too much. Programmers responsibility.
I wanted to make the code as short as possible.
Hans Bezemer
Okay, so based on what I'm seeing in this thread, Forth does not really
consider string manipulation as other languages such as C++, Java, and even
Basic. Everyone is giving good but different answers. But there is no
consistency - no formal way of handling this.
I think this is just a reflection of what Forth is used most for in the
industry. Embedded systems, robotics, etc., where strings really aren't
important.
Rick
> Okay, so based on what I'm seeing in this thread, Forth does not really
> consider string manipulation as other languages such as C++, Java, and even
> Basic. Everyone is giving good but different answers. But there is no
> consistency - no formal way of handling this.
Traditionally, no. However, Forth has been successfully used for
high-performace multi-user databases, even without a conventional set
of string operators.
Andrew.
I write a lot of batch scripts (windows 2000 commands) to quickly gather
information that I need, sometimes on our network or sometimes in some kind
of simple database or list. Here is a simple example:
net view > net.txt
for /f "tokens=1* delims=\ " %%i in (net.txt) do copy "\\%%i\c$\Program
Files\Firewall\security.log" c:\logs\security-%%i.log
Rick
Neat, I didn't know that you could really do such things with cmd.exe.
My net view gives the following
---------------------------
\\WINPUFFY
\\WORKHORSE ......
Der Befehl wurde erfolgreich ausgeführt.
Basically, you're just using the first word of a line to get the server
name, so for this application there is no magic necessary, you could
even define ---------------- and "Der" to behave like \, and
make \\servername execute your copy command and ignore the rest of the
line, too.
Then you could just run
net view | mySmartForthScript
later,
s.
I'm treating \ as a delimter so I can get the server name without the \\,
because I reuse it to distinguish the log file names. I'll dig around in my
scripts and find a better example that is more stringy.
Rick
Alright here is a simple command I have used to parse out certain lines and
output them to a text file.
find /I "connected to" < TENFOUR20021225.LOG > connectlog.txt
Not really a good example since it's just searching for entire entries
instead of tokenizing certain strings, but still a string example in it's
own way. Other languages require a much larger set of commands to
accomplish that.
I think the point of string manipulation/tokenizing is because you don't
always know what kind of data you're going to work with, or at least it's
going to be in an inconsistent format.
Rick
untested, but hopefully it conveys the idea:
: pure-name ( xt -- addr n ) >name count 2- swap 2+ swap ;
: server ( compile: "\\server " -- ) ( run: -- )
create does> >code pure-name copy-command ;
: copy-command ( addr n -- ) \ where addr n is your %%i
s.
> Okay, so based on what I'm seeing in this thread, Forth does not really
> consider string manipulation as other languages such as C++, Java, and even
> Basic. Everyone is giving good but different answers. But there is no
> consistency - no formal way of handling this.
Yes. And if you think the string situation is not optimal, just try
asking about object programming. Wait, no, don't. Don't open that
issue again. It's a bit painful.
> I think this is just a reflection of what Forth is used most for in the
> industry. Embedded systems, robotics, etc., where strings really aren't
> important.
You may be right. On the other hand, you *can* have sophisticated
string handling in Forth that gives up *nothing* to other languages in
terms of features and ease of use. However you may have to use someone
else's extensions or write your own, depending on which Forth you are
using and what came with it.
Regards,
-Doug
Actually, I think the string situation _is_ optimal. There are some basic
operators, and beyond that it is easy to add the specific additional
operators you need. I've worked on a number of data base and
string-oriented applications, and their needs differed. The string
extensions that were perfect for some were irrelevant to others. Forth
doesn't attempt to provide an immense set of generalized tools, but rather
to present a small, simple system in which you can easily make customized
tools.
> > I think this is just a reflection of what Forth is used most for in the
> > industry. Embedded systems, robotics, etc., where strings really aren't
> > important.
>
> You may be right. On the other hand, you *can* have sophisticated
> string handling in Forth that gives up *nothing* to other languages in
> terms of features and ease of use. However you may have to use someone
> else's extensions or write your own, depending on which Forth you are
> using and what came with it.
Exactly.
Cheers,
Elizabeth
--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310-491-3356
5155 W. Rosecrans Ave. #1018 Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
==================================================
>Okay, so based on what I'm seeing in this thread, Forth does not really
>consider string manipulation as other languages such as C++, Java, and even
>Basic. Everyone is giving good but different answers. But there is no
>consistency - no formal way of handling this.
>
>I think this is just a reflection of what Forth is used most for in the
>industry. Embedded systems, robotics, etc., where strings really aren't
>important.
There are complex Forth applications (e.g. www.ccssa.com) with
major string support (and database support) in daily use all
over the world - and they run on PCs.
It is however true that the "formal" in the sense of standard
support is not high. This is a reflection of Forth's focussed
toolbox approach and the consequent lack of common practise
among users.
Even in the embedded domain, string support for displays and
web servers is a growing requirement that we support.
Stephen
--
Stephen Pelc, steph...@INVALID.mpeltd.demon.co.uk
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeltd.demon.co.uk - free VFX Forth downloads
> Actually, I think the string situation _is_ optimal. There are some basic
> operators, and beyond that it is easy to add the specific additional
> operators you need. I've worked on a number of data base and
> string-oriented applications, and their needs differed. The string
> extensions that were perfect for some were irrelevant to others. Forth
> doesn't attempt to provide an immense set of generalized tools, but rather
> to present a small, simple system in which you can easily make customized
> tools.
As time goes by I am seeing Forth in this light more and more. In other
words, I am agreeing with you, despite my previous post. I am even
reaching the conclusion that object standards are not so important, if
they are important at all. Forth has so much going for it that to
expect perfect standardization in every aspect is perhaps asking too
much, and may even be asking for the wrong thing.
Thanks for the wake-up call.
-Doug
I've added a constant to minimize the change of corruption (under normal usage).
1 cells constant sp
2 cells constant s0
8 cells constant slack
: s@ @ @ count ; ( s -- a n)
: s> dup @ tuck cell- swap ! @ count ; ( s -- a n)
\ initialize the stack
: string-stack ( a n --)
chars over + over over over ( a s0 a s0 a)
sp + ! s0 + tuck ! swap ! ( --)
;
\ put a string on the stack
: >s ( a n s --)
over 1+ chars over sp + @ swap - ( a n s p)
over @ cell+ dup >r slack + over > ( a n s p f)
if drop 2dup s0 + @ swap 1+ chars - then
>r -rot r@ place r@ over ( s p s)
sp + ! r> r@ ! r> swap ! ( --)
;
Hans Bezemer
include stringstack.f
\ split the top string stack element into several elements
: tokenize$ ( delimiter -- )
begin dup scan$ \ search next delimiter
?dup while \ next delimiter found:
negate split$ \ cut string at delimiter
dup skip$ right$ \ remove delimiter(s)
repeat drop ;
: richard ( -- )
s" Apple for the teacher" push$
bl tokenize$ \ split string into tokens
s" for" search$ \ search for this token, return index
if ." found at position " . then
;
Hope that helps,
CaffeineJunkie
Elizabeth is one person that has been successful at creating database and
string-oriented applications. She and her customer(s) will be the only
people to ever benefit from that development.
Forth is already in an optimal state to allow quick and extremely efficient
customizations to accomplish a task. If you're an expert at Forth. But that
is the real issue - we have a small group of experts in this newsgroup. They
are so good at what they do, they fail to see that there are exponentially
more people that cannot achieve these same objectives by starting from
scratch.
Rick
Ahah, now we're talking. An available Forth string tokenizer. :-) And
it's done so much more elegantly than the Java equivilent.
Rick
> "Doug Hoffman" <dhof...@journey.com> wrote in message
> news:dhoffman-52D2F5...@journey.net.client.newsread.com...
>> In article <9dydnYi0m-B...@vel.net>,
>> "Elizabeth D Rather" <era...@forth.com> wrote:
>>
>> > Actually, I think the string situation _is_ optimal. There are some
> basic
>> > operators, and beyond that it is easy to add the specific additional
>> > operators you need. I've worked on a number of data base and
>> > string-oriented applications, and their needs differed. The string
>> > extensions that were perfect for some were irrelevant to others. Forth
>> > doesn't attempt to provide an immense set of generalized tools, but
> rather
>> > to present a small, simple system in which you can easily make
> customized
>> > tools.
>>
>> As time goes by I am seeing Forth in this light more and more. In other
>> words, I am agreeing with you, despite my previous post. I am even
>> reaching the conclusion that object standards are not so important, if
>> they are important at all. Forth has so much going for it that to
>> expect perfect standardization in every aspect is perhaps asking too
>> much, and may even be asking for the wrong thing.
>>
>> Thanks for the wake-up call.
> Elizabeth is one person that has been successful at creating
> database and string-oriented applications. She and her customer(s)
> will be the only people to ever benefit from that development.
Which development are you talking about? I can't tell from your
message.
> Forth is already in an optimal state to allow quick and extremely
> efficient customizations to accomplish a task. If you're an expert
> at Forth.
Well, yes, in the same sense that there is no royal road to
mathematics. But there's nothing special about Forth in that regard.
> But that is the real issue - we have a small group of experts in
> this newsgroup. They are so good at what they do, they fail to see
> that there are exponentially more people that cannot achieve these
> same objectives by starting from scratch.
Cannot? Why not?
In any case, people aren't going to achieve that level of expertise by
calling a bunch of canned libraries.
Forth has always been different, and one of the most distinctive of
its features is its implicity. Much of Forth's power is a consequence
of that simplicity.
Andrew.
So the question is - would so many programmers develop their applications
more efficiently if those libraries were not available, or would those
applications never had been developed?
Rick
And your reply is?
>> In any case, people aren't going to achieve that level of expertise by
>> calling a bunch of canned libraries.
> So the question is - would so many programmers develop their
> applications more efficiently if those libraries were not available,
> or would those applications never had been developed?
Presumably the latter. But that doesn't imply that adding
everything-but-the-kitchen-sink libraries is necessarily the right
thing for Forth.
Your argument seemed to be that
a. Forth is powerful in the hands of experts
b. but not everyone is an expert
therefore change Forth.
I'm saying this doesn't follow -- it might be better for people to
become experts.
Andrew.
Not everyone is an artist, not everyone is right handed. Some people are
really good at solving problems by starting from the ground up and using
their imagination. Others are really good at solving problems by taking
already existing solutions and putting them together to meet an objective.
This is just my observation of the world.
>
> >> In any case, people aren't going to achieve that level of expertise by
> >> calling a bunch of canned libraries.
>
> > So the question is - would so many programmers develop their
> > applications more efficiently if those libraries were not available,
> > or would those applications never had been developed?
>
> Presumably the latter. But that doesn't imply that adding
> everything-but-the-kitchen-sink libraries is necessarily the right
> thing for Forth.
That statements makes me think you personify Forth as some kind of child
that needed watched over. Or did you mean "the right thing for the Forth
community"?
>
> Your argument seemed to be that
>
> a. Forth is powerful in the hands of experts
> b. but not everyone is an expert
>
> therefore change Forth.
Would making standard libraries available to programmers change Forth, or
simply extend it without penalty to those that still tinker at the lowest
level?
Rick
> Not everyone is an artist, not everyone is right handed.
> Some people are really good at solving problems by starting from the
> ground up and using their imagination. Others are really good at
> solving problems by taking already existing solutions and putting
> them together to meet an objective. This is just my observation of
> the world.
That's interesting. IME the one common quality of anyone who is
intellectually successful is an overwhelming curiosity about how
things work.
I remember once going to a job interview and being asked to write a
short program to do something simple. Then, the interviewer asked me
"what code would the compiler you use generate for that program?"
That question, as they say, really separates the sheep from the goats.
>> >> In any case, people aren't going to achieve that level of expertise by
>> >> calling a bunch of canned libraries.
>>
>> > So the question is - would so many programmers develop their
>> > applications more efficiently if those libraries were not available,
>> > or would those applications never had been developed?
>>
>> Presumably the latter. But that doesn't imply that adding
>> everything-but-the-kitchen-sink libraries is necessarily the right
>> thing for Forth.
> That statements makes me think you personify Forth as some kind of
> child that needed watched over.
That's in your head, not anything I said!
> Or did you mean "the right thing for the Forth community"?
Certainly not.
>> Your argument seemed to be that
>>
>> a. Forth is powerful in the hands of experts
>> b. but not everyone is an expert
>>
>> therefore change Forth.
> Would making standard libraries available to programmers change
> Forth, or simply extend it without penalty to those that still
> tinker at the lowest level?
An important feature of Forth is that it is very simple, so its source
can be read and understood fully by its users. This is different from
conventional programming languages, whose implementation is so complex
that it might take several years to understand. This simplicity is
highly empowering to the user.
It is possible to add to Forth everything that is "missing". However,
doing so takes away the property that its implementation is very
simple. Also, doing so might well *increase* the maintenance cost of
Forth code because there is a great deal more to learn about the
system and its implementation.
Andrew.
I have a number of cameras. One of them is a super-duper
all-singing-and-dancing whizzbang digital job. It has many
advantages, especially if I'm in a hurry. I also have a camera that
is totally manual: no batteries, no exposure meter, nothing. It has a
single fixed-length lens and a rangefinder. (There are even simpler
cameras that don't even have viewfinders. They have their virtues
too.)
Would that manual camera be better if it had auto-focus,
auto-exposure, and so on? I don't believe it would; instead it would
become a different kind of thing. The tools we use have a profound
effect on our thinking. [*]
"To gain knowledge, add something every day; to gain wisdom, remove
something every day" -Lao Tzu
Andrew.
[*] Para from EWD498
> Would making standard libraries available to programmers change Forth, or
> simply extend it without penalty to those that still tinker at the lowest
> level?
Forth is not a language: it is a programming methodology (those
promoting specific Forth-based languages try to obfuscate this). Forth
programmers solve problems by creating custom languages whose
characteristics match the problem domain.
There are some common points: the methodolology requires stacks and a
dictionary, and one must reveal the basic capabilities of the underlying
hardware. There are therefore Forth languages, and they tend to have a
lot in common. String handling, however, is not a common point among Forths.
String handling resists standardization. It is not a primitive hardware
function. What do you mean by "string"? Is it as simple as an array of
characters, or is it as complex as an NSTextView object in Cocoa? For
that matter, what do you mean by "character" in this age of
internationalized code? How should string handling deal with buffer
overflows? How should string handling avoid memory leaks? Much of the
bloat afflicting so many C applications results from the attempts of
library and toolkit writers to provide universal solutions to these issues.
Instead, Forth makes it practical to build the specialized string
operators that meet the specific requirements of your application. This
makes for a little more low level work, but often pays off by making the
high level stuff easier and leaner.
Of course, if you like, say, the AWK model of string handling, you may
go ahead and implement it in your favorite Forth. Don't expect it to be
terribly popular though: ideologues won't like it, pragmatists will just
continue to use AWK instead of Forth when that makes sense, and those
who use a different Forth from yours won't be able to use your definitions.
-jpd
>> Would making standard libraries available to programmers change Forth, or
>> simply extend it without penalty to those that still tinker at the lowest
>> level?
> Forth is not a language: it is a programming methodology (those
> promoting specific Forth-based languages try to obfuscate this).
Or those who disagree, even. Horrors.
Andrew.
The lists.4th code was ported to PFE and Gforth with only trivial
mods to the kForth version. I found that Gforth's defn of NUMBER?
is different than the one given in Brodie's Starting Forth, and
worked around this. The lists code may be found in
ftp://ccreweb.org/software/pfe/
and
ftp://ccreweb.org/software/gforth/
The file strings.4th [.fs] is needed by lists.4th [.fs]. Examples
of usage are given in test-lists.4th [.fs].
Krishna Myneni