>> It works ok. I would be very interested in seeing how it compares in spee=
>d to using Allocate et al... =20
>>=20
>> Hugh can you run some tests when you have some time?
>I would like to get a program that does a lot of string-handling --- perhap=
>s a port of an old QBASIC program --- and use that as a demonstration of my=
> string-stack.4th. A program like this might also make for a good benchmark=
>. Any suggestions would be appreciated.
>> I implemented Allocate for my own amusement and it seems much more compli=
>cated that simply grabbing some free space quickly and then setting a varia=
>ble to 0 when you are finished.
>Allocate varies a lot in speed from one Forth system to another. This also =
>depends upon the OS underneath. For the most part, allocate is pretty slow.=
> It is necessary to use the heap though, if you are going to support string=
>s of any size --- I think this is important, as that old 255 char limit is =
>something that we want to put in the past and forget about.
>> However the efficiency of cutting up stack strings is very impressive. B=
>eats copying or allocating every time I should think.
>I have two kinds of strings on the string-stack, which are "unique" and "de=
>rivative." A unique string is one that is on the heap. A derivative string =
>is one that is inside of a unique string. A derivative string is indicated =
>by having a negative cnt value. I have these kinds of words:
That is a neat trick, and I like the following analysis, which could be
a basis for a good practical package.
>1.) JUGGLERS --- These include SWAP$ etc. and they just move items around o=
>n the string-stack.
>2.) DUPLICATORS --- These include DUP$ etc. and they make a derivative item=
>.
>3.) CONSUMERS --- These include .$ etc. and they consume an item. If the it=
>em is a derivative it is just dropped. If the item is a unique, then FIX-DE=
>RIVATIVES is called first (this searches the string-stack for derivatives t=
>hat are inside of this unique and changes them into uniques) and then it is=
> dropped.
>4.) MUTATORS --- These include UCASE$ etc. and they modify an item. If the =
>item is a derivative it gets changed into a unique first, and if the item i=
>s a unique then FIX-DERIVATIVES gets called first, then the item is modifie=
>d.
>Because the DUPLICATORS put the derivative on top of the string-stack, you =
>generally have derivatives above their uniques on the string-stack. This is=
> good because a CONSUMER or MUTATOR of a derivative is faster than of a uni=
>que. For the most part, we can avoid doing ALLOC and DEALLOC because we are=
> working with derivatives. This plan gets messed up when SWAP$ or ROT$ etc.=
> are used and we end up with a unique above its derivatives on the string-s=
>tack --- then when we do a CONSUMER or MUTATOR of the unique we end up havi=
>ng to call FIX-DERIVATIVES which is the speed-killer --- this should be pre=
>tty rare in most programs however, because SWAP$ and ROT$ etc. tend to be p=
>retty rare.
I would like to extend the analysis by the following.
If you swap derived strings there is no problem. Only if you juggle
a derived string under a unique string there may be problems. In both
SWAP$ and ROT$ that can only be the case if the new string on top is
unique. It suffices to replace the one (swap) or two (rot) strings
by uniques if they are derived.
>You asked above for a speed benchmark. This is somewhat difficult because i=
>t depends upon what a typical program is like (how much SWAP$ and ROT$ etc.=
> are used). Since we don't actually have any programs at this time, it is s=
>omewhat early to say anything about what a typical program would be like.
The allocate contained in ciforth would be suitable, as it uses the first
free space available. You can just copy it from lina's forth.lab, or mail
me for a more heavily commented version.
>BTW: My ultimate goal with all of this is to write a program that can trans=
>late Esperanto into English or Spanish or whatever. I thought of this way b=
>ack in 1984 when I was learning Esperanto. It is too difficult for a progra=
>m to translate directly from Spanish to English or vice-versa because those=
> language are difficult to figure out (this was true 30 years ago and is st=
>ill true). By making the human write in Esperanto however, most of the work=
> can be dumped on the human. Translating from Esperanto to English or Spani=
>sh should be possible. All the Esperanto words have a suffix that tells you=
> exactly what part of speech they are. In string-stack.4th I have functions=
> for working with prefixes and suffixes that I provided specifically for ta=
>king apart Esperanto words. The idea is that the front-end of the program b=
>uilds a lexical tree for the Esperanto sentence. There would be a back-end =
>of the program specific to each output language that converts the lexical t=
>ree into English, Spanish, etc..
That is interesting. A collegue of mine Toon Witkam had this idea of translating
into Esperanto to disambiguate natural language. It turned into a project
for the EU and earned him a doctorate, later he became professor.
The EU didn't really like it too much, at the time it was slow (80's),
but mostly they didn't want too clear language in their treatises.
That was a multi-manyear project. I don't see you pull off a similar project
without a team.
>BTW: It was Marcos Cruz who got me thinking about Esperanto --- I haven't g=
>iven any thought to that subject in almost 30 years --- at one time though,=
> I did know a little about the subject.
Groetjes Albert
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&
c.xs4all.nl &=n
http://home.hccnet.nl/a.w.m.van.der.horst