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


Groups > comp.lang.forth > #32106 > unrolled thread

Reduce dictionary lookups using LIT ?

Started by"Rod Pemberton" <dont_use_email@xnothavet.cqm>
First post2014-07-01 20:24 -0400
Last post2014-07-03 20:02 +0100
Articles 7 on this page of 27 — 11 participants

Back to article view | Back to comp.lang.forth


Contents

  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

Page 2 of 2 — ← Prev page 1 [2]


#32147

FromStefan Mauerhofer <smauerhofer@androsoft.ch>
Date2014-07-03 02:41 -0700
Message-ID<ce8416eb-ccf2-41ad-b386-f8035238b382@googlegroups.com>
In reply to#32106
Numbers did impact the compilation speed in my Forth. For each number the dictionary had to be searched just to notice that there is no such word.
So I changed the parsing step a little. If the first character of word is a # then the it tries to convert the remaining characters into a number. On no success the dictionary is searched, effectively reversing the lookup-number order. It is still  (almost) compatible with standard forth.

10 0 do ... loop

is now

#10 #0 do ... loop

while the old one is still working (but parsed a little bit slower).

[toc] | [prev] | [next] | [standalone]


#32148

From"Alex McDonald" <blog@rivadpm.com>
Date2014-07-03 11:44 +0100
Message-ID<lp3c79$709$1@dont-email.me>
In reply to#32147
on 03/07/2014 10:41:31, Stefan Mauerhofer wrote:
> It is still  (almost) compatible with standard forth.

To some precision of the value "almost". That is, zero.

[toc] | [prev] | [next] | [standalone]


#32150

FromStefan Mauerhofer <smauerhofer@androsoft.ch>
Date2014-07-03 06:03 -0700
Message-ID<b75f9f11-a8cf-42fa-a7ec-e09845d3f782@googlegroups.com>
In reply to#32148
Am Donnerstag, 3. Juli 2014 12:44:57 UTC+2 schrieb Alex McDonald:
> on 03/07/2014 10:41:31, Stefan Mauerhofer wrote:
> 
> > It is still  (almost) compatible with standard forth.
> 
> 
> 
> To some precision of the value "almost". That is, zero.

Not exactly. Assume we have a word "#0" then my parser would recognize the number 0 while standard Forth would find the word "#0". So it is not 100% compatible, but good enough for most cases.

[toc] | [prev] | [next] | [standalone]


#32152

From"Alex McDonald" <blog@rivadpm.com>
Date2014-07-03 15:16 +0100
Message-ID<lp3oje$nvc$1@dont-email.me>
In reply to#32150
on 03/07/2014 14:03:15, Stefan Mauerhofer wrote:
> Am Donnerstag, 3. Juli 2014 12:44:57 UTC+2 schrieb Alex McDonald:
>> on 03/07/2014 10:41:31, Stefan Mauerhofer wrote:
>>
>> > It is still  (almost) compatible with standard forth.
>>
>>
>>
>> To some precision of the value "almost". That is, zero.
> 
> Not exactly. Assume we have a word "#0" then my parser would recognize
> the number 0 while standard Forth would find the word "#0". So it is
> not 100% compatible, but good enough for most cases.
> 

Since Forth200x, the number #0 would be recognised as zero; there are
numeric prefixes such as # for decimal, $ for hex and so on. So this

hex
#10
decimal .

should print 10, not 16. But this

: #20 ." twenty" ;
#20

should print twenty, not put 20 on the stack. The dictionary is searched
beofre attempting conversion to a number in a standard forth, and your
method is not standard. You either meet the requirements of the standard
in this area 100% or 0%; there's no nearly. As my grandmother used to
say, nearly a hit is still a miss.

[toc] | [prev] | [next] | [standalone]


#32158

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2014-07-03 16:31 +0000
Message-ID<2014Jul3.183156@mips.complang.tuwien.ac.at>
In reply to#32152
"Alex McDonald" <blog@rivadpm.com> writes:
> You either meet the requirements of the standard
>in this area 100% or 0%; there's no nearly.

Hmm, I think all Forth systems have some issue or other where the
system does not behave as the standard prescribes.  If nobody notices,
it may be 0%, but it's still close enough to the standard for all
practical users.

OTOH, in the present case, if compilation speed was a problem, there
are probably a number of ways to speed that up without straying from
the standard.  Have they all been examined?

- 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/

[toc] | [prev] | [next] | [standalone]


#32168

From"Alex McDonald" <blog@rivadpm.com>
Date2014-07-03 19:58 +0100
Message-ID<lp4942$ibq$1@dont-email.me>
In reply to#32158
on 03/07/2014 17:31:55,  wrote:
> "Alex McDonald" <blog@rivadpm.com> writes:
>> You either meet the requirements of the standard
>>in this area 100% or 0%; there's no nearly.
> 
> Hmm, I think all Forth systems have some issue or other where the
> system does not behave as the standard prescribes. If nobody notices,
> it may be 0%, but it's still close enough to the standard for all
> practical users.

In this specific case, I disagree. It's sufficently out of alignment on
the standard processing of numbers that it really isn't practical in the
sense that a reasonable user would expect. Imagine the surprise when his
card playing game refuses to pay out on a winning hand. 

\ non numeric parts of card deck
1  constant #ace
11 constant #jack
12 constant #queen
13 constant #king

.. get-card dup #ace > if ... 

[toc] | [prev] | [next] | [standalone]


#32169

From"Alex McDonald" <blog@rivadpm.com>
Date2014-07-03 20:02 +0100
Message-ID<lp49bj$ke1$1@dont-email.me>
In reply to#32168
on 03/07/2014 19:58:13, "Alex McDonald" wrote:
> on 03/07/2014 17:31:55,  wrote:
>> "Alex McDonald" <blog@rivadpm.com> writes:
>>> You either meet the requirements of the standard
>>>in this area 100% or 0%; there's no nearly.
>>
>> Hmm, I think all Forth systems have some issue or other where the
>> system does not behave as the standard prescribes. If nobody notices,
>> it may be 0%, but it's still close enough to the standard for all
>> practical users.
> 
> In this specific case, I disagree. It's sufficently out of alignment
> on the standard processing of numbers that it really isn't practical
> in the sense that a reasonable user would expect. Imagine the surprise
> when his card playing game refuses to pay out on a winning hand.
> 
> \ non numeric parts of card deck
> 1  constant #ace
> 11 constant #jack
> 12 constant #queen
> 13 constant #king
> 

Duh, missed it. Insert hex here;

hex
> .. get-card dup #ace > if ...
> 

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.forth


csiph-web