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:00:25 -0400 Organization: Aioe.org NNTP Server Lines: 61 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:32141 On Wed, 02 Jul 2014 04:27:54 -0400, Mark Wills wrote: > I'd suggest LIT: or AS-LIT or something. I prefer LIT: > > : ONE ( -- 1 ) LIT: 1 ; I found a post by Peter Sovietov in Russian which used # . He coded one of the online Forth optimizers in Javascript. I decided to go ahead and just rename LIT as (LIT) . Apparently, some Forth-83 systems did this so they could use LIT as above. And, the updated online version of Leo Brodie's Starting Forth uses (LITERAL) . My own dictionary only used LIT twice, once in LITERAL and once where it shouldn't be, but will be for a while, until I can remove it, or change another definition. > The following definition works in my system: > > : LIT: ( "n" -- ) > BL WORD NUMBER ABORT" Not a legal number" > COMPILE LIT , ; IMMEDIATE I don't have ABORT" and I don't recall if my ABORT is exposed, i.e., in the dictionary, but, yes, the sample I posted works, at least with COMPILE . > Your system may use POSTPONE rather than COMPILE. Yes, I use COMPILE and [COMPILE] even though I have POSTPONE . It's clear to me as to which operation is being performed. I only used POSTPONE in the sample because I didn't want the conversation diversion on why I should use POSTPONE instead. > But... Is your system so slow that you need this? Rhetorical. > I'm sure it's not. No, it's not. The dictionary is compiled once. > I question the benefit this would bring... I was just thinking about if a dictionary or program became excessively large, doing large searches through the ENTIRE dictionary, just to NOT find something in the dictionary. I.e., seemed like an easy change to short-circuit the logic. > Is this a bootstrapping thing? No. My inner interpreter will (still) compile a run-time LIT and number, if the word is not found in the dictionary. > You're trying to minimise dictionary lookups [...] I understood that to be the point of using LIT that way. > [...] while the system is compiling/bootstrapping itself? At 3.2Ghz (probably obsolete now...), it isn't really needed. Rod Pemberton