Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #32116

Re: Reduce dictionary lookups using LIT ?

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Reduce dictionary lookups using LIT ?
Date 2014-07-02 09:35 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2014Jul2.113523@mips.complang.tuwien.ac.at> (permalink)
References <op.xicgra2o6zenlw@localhost>

Show all headers | View raw


"Rod Pemberton" <dont_use_email@xnothavet.cqm> writes:
>I saw a quote from a Forth book which said LIT was also
>useful to eliminate dictionary lookups of numbers when
>loading and compiling a vocabulary.
>
>So, instead of:
>
>: ONE 1 ;  \ LIT compiled by innner interpreter
>
>this would be used in a vocabulary:
>
>: ONE LIT 1 ;  \ LIT explicitly used
>
>Here, 1 is not searched for in the dictionary by the inner
>interpreter when compiling ONE due to the use of LIT .

But it does not reduce dictionary lookups, because you now have to
look up LIT.

We have such words for string literals (S"), but for integer and FP
numbers we let the text interpreter do the conversion if the
dictionary lookup fails.  While S" has been a headache (in connection
with ' and POSTPONE), no such problems were present when dealing with
integer or FP literals.  So a number of people have been thinking of
also putting string literals in the text interpreter, and that's now a
feature of the development version of Gforth and AFAIK has long been a
feature of Albert van der Horst's systems.

So I don't think that an integer literal parsing word is a good idea.

>I'd like to use that syntax in my vocabulary, but I think
>it creates some problems.  I already have a historically
>based run-time LIT which works differently.

Sure, the name LIT is widely used for the run-time routine of LITERAL
(e.g., in fig-Forth, and following from that, in Gforth).  So you
might want to use a different name for the parsing word, say INT.

>A new "high-level" LIT as used in ": ONE LIT 1 ;" would
>need to be something like the following:
>
>: LIT BL WORD NUMBER POSTPONE LITERAL ; IMMEDIATE
>
>Except, LITERAL calls the original run-time LIT:
>
>: LITERAL POSTPONE LIT , ; IMMEDIATE
>: LIT R> DUP "cell_adjustment" >R @ ;
>
>This creates a name conflict between the two LITs, since
>my vocabulary would need to use both at the same time.

Given that the traditional LIT is only an internal name, and programs
normally don't use it (they use LITERAL), you could live with the
parsing LIT shadowing the traditional LIT.  I still think it's a bad
idea, because it's confusing to have the same name for two different
words.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2014: http://www.euroforth.org/ef14/

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Reduce dictionary lookups using LIT ? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-07-01 20:24 -0400
  Re: Reduce dictionary lookups using LIT ? "Elizabeth D. Rather" <erather@forth.com> - 2014-07-01 19:39 -1000
    Re: Reduce dictionary lookups using LIT ? bruce.mcfarling@gmail.com - 2014-07-02 10:30 -0700
      Re: Reduce dictionary lookups using LIT ? "Elizabeth D. Rather" <erather@forth.com> - 2014-07-02 08:53 -1000
      Re: Reduce dictionary lookups using LIT ? Mark Wills <markwills1970@gmail.com> - 2014-07-02 13:47 -0700
        Re: Reduce dictionary lookups using LIT ? BruceMcF <agila61@netscape.net> - 2014-07-02 19:45 -0700
          Re: Reduce dictionary lookups using LIT ? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-07-03 16:56 +0000
            Re: Reduce dictionary lookups using LIT ? bruce.mcfarling@gmail.com - 2014-07-03 10:34 -0700
  Re: Reduce dictionary lookups using LIT ? Mark Wills <markwills1970@gmail.com> - 2014-07-02 01:27 -0700
    Re: Reduce dictionary lookups using LIT ? Bernd Paysan <bernd.paysan@gmx.de> - 2014-07-02 17:11 +0200
      Re: Reduce dictionary lookups using LIT ? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-07-02 16:31 +0000
        Re: Reduce dictionary lookups using LIT ? Bernd Paysan <bernd.paysan@gmx.de> - 2014-07-02 20:32 +0200
      Re: Reduce dictionary lookups using LIT ? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-07-03 03:01 -0400
        Re: Reduce dictionary lookups using LIT ? "Elizabeth D. Rather" <erather@forth.com> - 2014-07-02 21:42 -1000
        Re: Reduce dictionary lookups using LIT ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-07-03 16:05 +0000
    Re: Reduce dictionary lookups using LIT ? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-07-03 03:00 -0400
  Re: Reduce dictionary lookups using LIT ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-07-02 09:35 +0000
    Re: Reduce dictionary lookups using LIT ? "Elizabeth D. Rather" <erather@forth.com> - 2014-07-02 06:51 -1000
  Re: Reduce dictionary lookups using LIT ? chitselb <chitselb@gmail.com> - 2014-07-02 14:30 -0700
    Re: Reduce dictionary lookups using LIT ? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-07-03 03:51 -0400
  Re: Reduce dictionary lookups using LIT ? Stefan Mauerhofer <smauerhofer@androsoft.ch> - 2014-07-03 02:41 -0700
    Re: Reduce dictionary lookups using LIT ? "Alex McDonald" <blog@rivadpm.com> - 2014-07-03 11:44 +0100
      Re: Reduce dictionary lookups using LIT ? Stefan Mauerhofer <smauerhofer@androsoft.ch> - 2014-07-03 06:03 -0700
        Re: Reduce dictionary lookups using LIT ? "Alex McDonald" <blog@rivadpm.com> - 2014-07-03 15:16 +0100
          Re: Reduce dictionary lookups using LIT ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-07-03 16:31 +0000
            Re: Reduce dictionary lookups using LIT ? "Alex McDonald" <blog@rivadpm.com> - 2014-07-03 19:58 +0100
              Re: Reduce dictionary lookups using LIT ? "Alex McDonald" <blog@rivadpm.com> - 2014-07-03 20:02 +0100

csiph-web