Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: Reduce dictionary lookups using LIT ? Date: Thu, 03 Jul 2014 03:01:29 -0400 Organization: Aioe.org NNTP Server Lines: 47 Message-ID: References: NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:32142 On Wed, 02 Jul 2014 11:11:11 -0400, Bernd Paysan wrote: > Mark Wills wrote: >> But... Is your system so slow that you need this? Rhetorical. > > It's a Rod Pemberton idea. Assume it to be wrong in every way. It came from a partial quote from a book in Google Books which came up when I searched for LITERAL or LIT or something. Of course, it was probably from the 1980's and not that common a thing. Another quote seems to indicate it was a Forth-83 thing. > In this case, the lookup for names comes before the lookup for > numbers, so if you find a name, you are done, the time for number > conversion isn't necessary. However, if he has a linear search, > and LIT (or maybe D# and H#, a they are used in some Forths to > denote specific bases rather than having the base prefixes) is > found pretty early, then there is a benefit. However, as such > word would be defined pretty early (needed all the time), it is > unlikely that you gain something. The gain is likely neglible. As "bruce.mcfarling" noted, the entire dictionary is no longer searched it's entirety, but the dictionary is still partially searched to find LIT. > If you have lots of literals, a slow dictionary search, and your > Forth words don't conflict with literals (they usually shouldn't, > at least in decimal mode), you could turn the search around: First > try to convert as literal, and if that fails, search. This would > give a benefit, as indentifying a number is pretty fast, and in > the "many literals" case the search is completed when it's a literal. In an optimized compiled Forth, I'd expect that attempting the number conversion first to add a slight overhead per word that would be far less than a partial dictionary search for LIT. In a threaded-interpreted Forth, I'd expect the ITC or DTC number conversion routine to take much longer, perhaps comparable to a full dictionary search. There is much looping and division. > With Gforth's development version, you can shuffle the recognizer > stack to give it a try. But Gforth has a fast dictionary lookup ... ... Rod Pemberton