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


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

Given a string, create word with that name (in ANS Forth)?

Started byAlex Dowad <alexinbeijing@gmail.com>
First post2016-09-11 06:12 -0700
Last post2016-09-12 14:08 +0200
Articles 20 on this page of 96 — 19 participants

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


Contents

  Given a string, create word with that name (in ANS Forth)? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-11 06:12 -0700
    Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-11 10:51 -0500
      Re: Given a string, create word with that name (in ANS Forth)? Alex Dowad <alexinbeijing@gmail.com> - 2016-09-11 09:49 -0700
      Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-11 19:57 +0200
        Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-12 02:43 -0500
      Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-11 14:31 -0700
    Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-11 10:14 -0700
    Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-12 07:46 +0000
      Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-12 01:10 -0700
        Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-12 09:01 +0000
          Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 14:02 +0200
            Re: Given a string, create word with that name (in ANS Forth)? "HAA" <someone@microsoft.com> - 2016-09-20 12:06 +1000
              Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-20 11:27 +0200
          Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-12 13:02 -0700
            Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-13 16:20 +0000
              Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-13 21:08 +0200
                Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-13 17:30 -0700
                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-14 07:11 +0000
                    Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-14 18:30 -0700
            Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-15 02:46 -0500
            Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-20 14:27 -0700
              Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-20 15:05 -0700
                Re: Given a string, create word with that name (in ANS Forth)? Melzzzzz <Melzzzzz@zzzzz.com> - 2016-09-20 22:19 +0000
              Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-21 12:26 +0000
                Re: Given a string, create word with that name (in ANS Forth)? Coos Haak <htrofhc@gmail.com> - 2016-09-21 15:11 +0200
                  Re: Given a string, create word with that name (in ANS Forth)? mhx@iae.nl - 2016-09-21 10:06 -0700
                    Re: Given a string, create word with that name (in ANS Forth)? Coos Haak <htrofhc@gmail.com> - 2016-09-21 21:12 +0200
                Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-21 12:06 -1000
                  Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-21 15:40 -0700
                    Re: Given a string, create word with that name (in ANS Forth)? "HAA" <someone@microsoft.com> - 2016-09-22 13:04 +1000
                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-22 07:40 +0000
                    Re: Given a string, create word with that name (in ANS Forth)? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-22 15:46 +0100
                      Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-22 11:08 -0700
                      Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-22 22:04 +0200
                        Re: Given a string, create word with that name (in ANS Forth)? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-23 10:21 +0100
                          Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-23 12:06 +0200
                            Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-23 10:44 -0500
                              Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-23 16:26 +0000
                                Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-24 03:46 -0500
                                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-24 10:13 +0000
                                    Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-24 10:34 -0500
                                      Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-24 20:19 +0200
                                        Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-24 09:47 -1000
                                          Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-24 14:29 -0700
                                            Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-24 13:00 -1000
                                              Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-24 16:19 -0700
                                              Re: Given a string, create word with that name (in ANS Forth)? jim.brakefield@ieee.org - 2016-09-24 19:02 -0700
                                                Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-24 21:23 -1000
                                                  Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-25 19:08 -0700
                                                    Re: Given a string, create word with that name (in ANS Forth)? jim.brakefield@ieee.org - 2016-09-25 19:53 -0700
                                                      Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-25 20:00 -0700
                                              Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-25 17:40 -0700
                                            Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-25 01:42 -0500
                                              Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-24 23:45 -0700
                                                Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-25 02:22 -0500
                                                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-26 15:31 +0000
                                                    Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-26 10:42 -0500
                                                      Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-27 15:57 +0000
                                                        Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 19:11 +0200
                                                Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-24 21:28 -1000
                                            Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-25 18:55 -0700
                                          Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-25 09:35 +0200
                                          Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-26 15:38 +0000
                                            Re: Given a string, create word with that name (in ANS Forth)? hughaguilar96@gmail.com - 2016-09-26 12:36 -0700
                                      Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-24 20:26 +0200
                                      Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-25 15:22 +0000
                                        Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-25 10:44 -0700
                                          Re: Given a string, create word with that name (in ANS Forth)? Coos Haak <htrofhc@gmail.com> - 2016-09-25 19:55 +0200
                                            Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-25 20:15 +0200
                                              Re: Given a string, create word with that name (in ANS Forth)? Coos Haak <htrofhc@gmail.com> - 2016-09-25 20:26 +0200
                                            Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-25 11:12 -0700
                                              Re: Given a string, create word with that name (in ANS Forth)? Julian Fondren <julian.fondren@gmail.com> - 2016-09-25 11:30 -0700
                                              Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-26 14:51 +0000
                                                Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-27 14:16 +0200
                            Re: Given a string, create word with that name (in ANS Forth)? "Elizabeth D. Rather" <erather@forth.com> - 2016-09-23 07:52 -1000
                        Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-23 10:36 -0500
      Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 13:55 +0200
        Re: Given a string, create word with that name (in ANS Forth)? Lars Brinkhoff <lars.spam@nocrew.org> - 2016-09-12 15:01 +0200
        Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-12 17:29 +0000
          Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 21:02 +0200
            Re: Given a string, create word with that name (in ANS Forth)? Paul Rubin <no.email@nospam.invalid> - 2016-09-12 13:04 -0700
              Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 22:33 +0200
                Re: Given a string, create word with that name (in ANS Forth)? lawrencedo99@gmail.com - 2016-09-16 18:38 -0700
                  Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-17 05:33 +0000
                    Re: Given a string, create word with that name (in ANS Forth)? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-09-17 01:40 -0500
                    Re: Given a string, create word with that name (in ANS Forth)? lawrencedo99@gmail.com - 2016-09-16 23:47 -0700
                      Re: Given a string, create word with that name (in ANS Forth)? Julian Fondren <julian.fondren@gmail.com> - 2016-09-17 00:08 -0700
                      Re: Given a string, create word with that name (in ANS Forth)? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-17 17:03 +0000
              Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 22:35 +0200
              Re: Given a string, create word with that name (in ANS Forth)? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-09-17 08:16 +0100
    Re: Given a string, create word with that name (in ANS Forth)? Mark Wills <markwills1970@gmail.com> - 2016-09-12 02:49 -0700
      Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 14:04 +0200
      Re: Given a string, create word with that name (in ANS Forth)? Cecil Bayona <cbayona@cbayona.com> - 2016-09-12 09:34 -0500
        Re: Given a string, create word with that name (in ANS Forth)? Mark Wills <markwills1970@gmail.com> - 2016-09-12 08:10 -0700
          Re: Given a string, create word with that name (in ANS Forth)? Cecil Bayona <cbayona@cbayona.com> - 2016-09-12 12:02 -0500
    Re: Given a string, create word with that name (in ANS Forth)? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-09-12 14:08 +0200

Page 4 of 5 — ← Prev page 1 2 3 [4] 5  Next page →


#51305

Fromhughaguilar96@gmail.com
Date2016-09-25 18:55 -0700
Message-ID<f7f0aadf-54fd-48e2-9d35-7b056fa56340@googlegroups.com>
In reply to#51250
On Saturday, September 24, 2016 at 2:30:01 PM UTC-7, Paul Rubin wrote:
> "Elizabeth D. Rather" <erather@forth.com> writes:
> >> "mapping" or "associative array" or something.
> > The thing is, each of those application areas has its own needs. The
> > dictionary is, itself, an application with certain needs, and
> > complicating the dictionary to make a general-purpose facility will
> > not benefit either Forth or any of those uses.
> 
> Associative tables have shown themselves to be a very useful datatype in
> many other languages, and the implementation details are usually not
> that important.  Forth uses one to implement dictionaries/wordlists, but
> its interface is very restricted.  And if the application implements its
> own, but that means there are now two different implementations in the
> Forth running the app.
> 
> If a general purpose table had been available from the beginning, the
> Forth dictionary would be able to use it, and the user app could use it
> too.

In Straight Forth I have two built-in data-structures, which are arrays and chains. I just made up the term "chain" --- I standardize behavior not implementation, so I didn't want to describe how it is implement --- I will say here though that it is (at this time) an AVL tree, and each node has an up pointer as well as down-left and down-right pointers (the up-pointer allows LEFT and RITE to work).

The programmer is expected to write his program using these two built-in data-structures if possible, and to only implement another data-structure if absolutely necessary. I would expect that 99% of all programs will just use the two built-in data-structures. The programmer is expect to never write explicit iteration code (using BEGIN WHILE REPEAT) --- the only exception would be in the hofs supporting a new data-structure --- so 99% of all programs will not have explicit iteration (they will just use the hofs associated with the two built-in data-structures).

Arrays are mostly for strings --- they may occasionally be useful for other kinds of data --- for the most part though, chains will be used for everything.

Here is an excerpt from my document:
------------------------------------

Chains are the primary data-structure in Straight Forth. In my novice-package (written in ANS-Forth) I used singly-linked lists as my primary data-structure, and I originally considered doubly-linked lists as the primary data-structure in Straight Forth. Chains can be used similarly to doubly-linked lists though, in that it is possible to move left or right one node at a time (with the LEFT and RITE functions), although chains may not be quite as fast at this because they sometimes have to move up and down in the tree to find the adjacent node. Chains can be used for random look-up similarly to hash-tables, although chains may not be quite as fast at this. Chains can be used for sparse arrays, which neither doubly-linked lists nor hash-tables are useful for. Chains can be used in a cross-compiler to hold the intermediate code, with the index being the line-number. All in all, chains are a great general-purpose data-structure --- I can't think of any data-structure that would be more generally useful.

Chains can be used as the symbol-table (the "dictionary" in Forth terminology) for the Forth system itself. You would have two chains representing the dictionary, one of which is keyed by the word names (used by FIND etc. for looking up words) and the other one of which is keyed by the order that the words were created (increment a count and convert it into a string for the key). This latter one would be used by MARKER words for deleting everything defined after the MARKER was defined. The two chains would cross-reference each other. Considering that chains are a general-purpose data-structure, it makes sense that chains should be used by the Forth system itself for its primary data-structure which is the dictionary.

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


#51268

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2016-09-25 09:35 +0200
Message-ID<86k2e0fn45.fsf@molnjunk.nocrew.org>
In reply to#51246
Elizabeth D. Rather wrote:
> The thing is, each of those application areas has its own needs. The
> dictionary is, itself, an application with certain needs, and
> complicating the dictionary to make a general-purpose facility will
> not benefit either Forth or any of those uses.

Like I wrote elsewhere, when I use a wordlist as an associative array, I
don't have any pressing needs.  So whatever performance characteristics
the Forth dictionary provides, that's ok with me in those circumstances.
And I'd rather avoid having to implement another data structure when an
existing one works fine.

This didn't complicate my dictionary implementation at all.  It just
fell out naturally.  Of course, I realise that may not be the case for
every other Forth.  But apparently some alreay have this facility
provided by NEXTNAME and POSTFIX.  I also heard about factors called
(CREATE) or $CREATE.

Note that I'm actually not advocating this facility at all.  I'm happy
to use it myself, in my own applications, in my own Forth.

I just pointed out that EXECUTE-PARSING can't handle arbitrary strings,
like NEXTNAME and POSTFIX can.

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


#51337

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-09-26 15:38 +0000
Message-ID<2016Sep26.173834@mips.complang.tuwien.ac.at>
In reply to#51246
"Elizabeth D. Rather" <erather@forth.com> writes:
>The thing is, each of those application areas has its own needs. The 
>dictionary is, itself, an application with certain needs, and 
>complicating the dictionary to make a general-purpose facility will not 
>benefit either Forth or any of those uses.

Bullshit.  There is no need to complicate the dictionary to make
general-purpose use of wordlists.  And the capabilities that wordlists
provide (insert and lookup) are sufficient for pretty much all the
uses I have for associative arrays.

As for performance: An implementation that is slow for general-purpose
use will also be slow for text-interpreter use, and vice versa, so
there is no conflict here.  And while using a hand-written associative
array may save some memory compared to a dictionary entry, this has
not been enough of a problem in my usage to make me avoid using
wordlists.

- 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 2016: http://www.euroforth.org/ef16/

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


#51343

Fromhughaguilar96@gmail.com
Date2016-09-26 12:36 -0700
Message-ID<9337d514-7582-4373-86de-a2bd1360c8a2@googlegroups.com>
In reply to#51337
On Monday, September 26, 2016 at 9:00:47 AM UTC-7, Anton Ertl wrote:
> "Elizabeth D. Rather" <erather@forth.com> writes:
> >The thing is, each of those application areas has its own needs. The 
> >dictionary is, itself, an application with certain needs, and 
> >complicating the dictionary to make a general-purpose facility will not 
> >benefit either Forth or any of those uses.
> 
> Bullshit.  There is no need to complicate the dictionary to make
> general-purpose use of wordlists.  And the capabilities that wordlists
> provide (insert and lookup) are sufficient for pretty much all the
> uses I have for associative arrays.

The needs of a dictionary are a subset of the features that would be provided by a general-purpose data-structure such as my "chain" --- so, Anton Ertl is right --- there is no need to complicate the dictionary.

My chains' features are expected to be a super-set of multiple applications, which is why they are suitable for being a general-purpose data-structure that can be used in multiple disparate applications --- they are not optimized for any particular application, which Elizabeth Rather considers to be of supreme importance.

I'm pretty dubious that optimizing for every application actually results in optimal code --- as a practical matter, nobody has time for this --- so you actually get mediocre results for every application.

In Straight Forth I have only two data-structures, so I can focus on making them fast --- they may not be the optimal data-structure for every application (hash-tables are faster if you don't need ordered traversal) --- they are in assembly-language though because they are a built-in part of the language, so they are going to be reasonably fast (hopefully fast enough).

The purpose of Straight Forth is to write useful programs --- given how fast today's computers are, it is not necessary to optimize the heck out of every program --- if you really need a fast program, then resort to assembly-language (hopefully you are getting paid well for your program, as writing in assembly-language is a pita).

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


#51245

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2016-09-24 20:26 +0200
Message-ID<86pontf934.fsf@molnjunk.nocrew.org>
In reply to#51241
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
> The question which arose was to do with the usage of the dictionary as
> a general-purpose lookup table for arbitrary strings.  The
> disadvantage of the dictionary for that purpose is that its
> performance varies widely

And in some cases, perfomance doesn't matter much.  For example, when I
use the dictionary in that way, I often only have a handful of entries.

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


#51285

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-09-25 15:22 +0000
Message-ID<2016Sep25.172229@mips.complang.tuwien.ac.at>
In reply to#51241
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>>>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>>>>My take on it is that the dictionary is a very specific structure
>>>>>which is optimized for the job it does.  It doesn't necessarily
>>>>>provide O(1) access, for example.
>>>> 
>>>> So what?  
>>>
>>>That was obvious from the context.
>>>
>>>> There are no performance guarantees anywhere in the Forth
>>>
>>>That was my point.  That was obvious from the context.
>> 
>> Which context?
>
>The context you deleted from the message to which I was replying.

If you mean, in <Tr2dnT8q6sFm0HjKnZ2dnUU7-cGdnZ2d@supernews.com>:

|Lars Brinkhoff <lars.spam@nocrew.org> wrote:
|
|> I guess it comes down to whether you view the dictionary as strictly
|> a symbol table for program identifiers, or if you want to be able to
|> use it as a more generic hash table indexed by strings.

No, I don't see that there is anything obvious from that context.

Looking at it again, maybe you intrepreted his use of "hash table" as
meaning "a O(1) access data structure for an associative array", while
I interpreted it just as "associative array", as has become general
usage (e.g.,
<https://en.wikipedia.org/wiki/Comparison_of_programming_languages_%28mapping%29>
says 'associative arrays (also "mapping", "hash", and "dictionary")'),
and was intended by the original author.

And "hash table" does not imply O(1) access anyway.  E.g., from
earlier postings I know that Forth, Inc. and MPE use hash tables for
wordlists, but they are not O(1) access.

>>>> Why should I use a system-specific interface?
>>>
>>>If the O(1) performance of a hash table is essential to your design,
>> 
>> Where did you get the idea that it was essential?
>
>Note the "if" in the statement above.

Ok, so it's an argument we can ignore.  Let's look at the rest of the
argument: Oops, there is no "otherwise" part, so there is nothing
left.

>Sure, but the system-specific interface *is* needed in the context
>where strings with embedded spaces are used as keys.  (Having said
>that, the strings can be encoded in some way, so the dictionary could
>be used even then, but it would be inconvenient.)

Yes, but in the taxi.fs case converting the numbers to strings was
still much easier than writing my own data structure.

Anyway, the discussion is about whether making something like NEXTNAME
standard may be a good idea.  Arguing that we don't need to make it
standard because it's system-specific at the moment is circular.

>The question which arose was to do with the usage of the dictionary as
>a general-purpose lookup table for arbitrary strings.  The
>disadvantage of the dictionary for that purpose is that its
>performance varies widely

Since when is that an argument?  The performance of the rest of Forth
also varies widely, that has not kept us from using or standardizing it.

> and that it doesn't accept arbitrary
>strings.

More precisely, we have no standard interface for inserting arbitrary
strings (and that's the issue under discussion); lookup
(SEARCH-WORDLIST) works nicely with arbitrary strings.  A more serious
issue is that WORDLISTs are case-insensitive in many systems.

- 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 2016: http://www.euroforth.org/ef16/

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


#51287

FromPaul Rubin <no.email@nospam.invalid>
Date2016-09-25 10:44 -0700
Message-ID<87zimv98ne.fsf@jester.gateway.pace.com>
In reply to#51285
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> Anyway, the discussion is about whether making something like NEXTNAME
> standard may be a good idea.

As an alternative to both NEXTNAME and EXECUTE-PARSING, what about 
something like EVAL ( a u -- ), which would simply take a string and
run it through the text interpreter?  The BLOCKS system has to be able
to do something like that already.  

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


#51288

FromCoos Haak <htrofhc@gmail.com>
Date2016-09-25 19:55 +0200
Message-ID<1qt0dtqn5ma2b.vjhau5ykvu3m.dlg@40tude.net>
In reply to#51287
Op Sun, 25 Sep 2016 10:44:21 -0700 schreef Paul Rubin:

> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> Anyway, the discussion is about whether making something like NEXTNAME
>> standard may be a good idea.
> 
> As an alternative to both NEXTNAME and EXECUTE-PARSING, what about 
> something like EVAL ( a u -- ), which would simply take a string and
> run it through the text interpreter?  The BLOCKS system has to be able
> to do something like that already.

Wasn't this called 6.1.1360 and 7.6.1.1360 EVALUATE already?

groet Coos

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


#51289

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-25 20:15 +0200
Message-ID<ns947s$8k2$1@cherry.spenarnc.xs4all.nl>
In reply to#51288
In article <1qt0dtqn5ma2b.vjhau5ykvu3m.dlg@40tude.net>,
Coos Haak  <htrofhc@gmail.com> wrote:
>Op Sun, 25 Sep 2016 10:44:21 -0700 schreef Paul Rubin:
>
>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>> Anyway, the discussion is about whether making something like NEXTNAME
>>> standard may be a good idea.
>>
>> As an alternative to both NEXTNAME and EXECUTE-PARSING, what about
>> something like EVAL ( a u -- ), which would simply take a string and
>> run it through the text interpreter?  The BLOCKS system has to be able
>> to do something like that already.
>
>Wasn't this called 6.1.1360 and 7.6.1.1360 EVALUATE already?

Indeed EVALUATE is approximately
   'INTERPRET EXECUTE-PARSING
however now we want to do something different than INTERPRET.

>
>groet Coos
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

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


#51291

FromCoos Haak <htrofhc@gmail.com>
Date2016-09-25 20:26 +0200
Message-ID<xa651ehic08j.1rxuxpudlaypw.dlg@40tude.net>
In reply to#51289
Op Sun, 25 Sep 2016 20:15:24 +0200 (CEST) schreef Albert van der Horst:

> In article <1qt0dtqn5ma2b.vjhau5ykvu3m.dlg@40tude.net>,
> Coos Haak  <htrofhc@gmail.com> wrote:
>>Op Sun, 25 Sep 2016 10:44:21 -0700 schreef Paul Rubin:
>>
>>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>> Anyway, the discussion is about whether making something like NEXTNAME
>>>> standard may be a good idea.
>>>
>>> As an alternative to both NEXTNAME and EXECUTE-PARSING, what about
>>> something like EVAL ( a u -- ), which would simply take a string and
>>> run it through the text interpreter?  The BLOCKS system has to be able
>>> to do something like that already.
>>
>>Wasn't this called 6.1.1360 and 7.6.1.1360 EVALUATE already?
> 
> Indeed EVALUATE is approximately
>    'INTERPRET EXECUTE-PARSING
> however now we want to do something different than INTERPRET.
> 
>>
>>groet Coos
> Groetjes Albert

Indeed, Gforth (and more implementations I presume) defines
  : EVALUATE ['] INTERPRET EXECUTE-PARSING ;

groet Coos

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


#51290

FromPaul Rubin <no.email@nospam.invalid>
Date2016-09-25 11:12 -0700
Message-ID<87vaxj97br.fsf@jester.gateway.pace.com>
In reply to#51288
Coos Haak <htrofhc@gmail.com> writes:
> Wasn't this called 6.1.1360 and 7.6.1.1360 EVALUATE already?

I thought that was different, based on having tried it before, but I'll
check.  It would seem to take care of all the requirements that have
been discussed so far, e.g., ." CREATE FOO" EVALUATE would create FOO
if EVALUATE really works like that.

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


#51292

FromJulian Fondren <julian.fondren@gmail.com>
Date2016-09-25 11:30 -0700
Message-ID<bbc42cc1-a2f5-4ad0-a828-078406587a48@googlegroups.com>
In reply to#51290
On Sunday, September 25, 2016 at 1:12:57 PM UTC-5, Paul Rubin wrote:
> Coos Haak <htrofhc@gmail.com> writes:
> > Wasn't this called 6.1.1360 and 7.6.1.1360 EVALUATE already?
> 
> I thought that was different, based on having tried it before, but I'll
> check.  It would seem to take care of all the requirements that have
> been discussed so far, e.g., ." CREATE FOO" EVALUATE would create FOO
> if EVALUATE really works like that.
                                                                          
: fiver ( c-addr u -- )                                                                                              
  s" create " pad place pad append                                                                                   
  pad count evaluate  1 , 2 , 3 , 4 , 5 , ;  ok                                                                      
s" foo" fiver  ok
foo 5 cells dump                                                                                                     
 8083A74 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 ................
 8083A84 05 00 00 00                                     ....             ok
: create true abort" create does something different now" ;                                                          
CREATE isn't unique.  ok
s" bar" fiver                                                                                                        
create bar create create does something different now

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


#51332

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-09-26 14:51 +0000
Message-ID<2016Sep26.165136@mips.complang.tuwien.ac.at>
In reply to#51290
Paul Rubin <no.email@nospam.invalid> writes:
>Coos Haak <htrofhc@gmail.com> writes:
>> Wasn't this called 6.1.1360 and 7.6.1.1360 EVALUATE already?
>
>I thought that was different, based on having tried it before, but I'll
>check.  It would seem to take care of all the requirements that have
>been discussed so far, e.g., ." CREATE FOO" EVALUATE would create FOO

No, that binds "CREATE" at run-time, and may result in completely
different behaviour than

s" FOO" ['] create execute-parsing

if a different CREATE is found at run-time, or if it is not found at
all.  See <https://www.complang.tuwien.ac.at/forth/why-evaluate-is-bad>.

- 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 2016: http://www.euroforth.org/ef16/

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


#51372

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-27 14:16 +0200
Message-ID<nsdnu4$ift$1@cherry.spenarnc.xs4all.nl>
In reply to#51332
In article <2016Sep26.165136@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>Paul Rubin <no.email@nospam.invalid> writes:
>>Coos Haak <htrofhc@gmail.com> writes:
>>> Wasn't this called 6.1.1360 and 7.6.1.1360 EVALUATE already?
>>
>>I thought that was different, based on having tried it before, but I'll
>>check.  It would seem to take care of all the requirements that have
>>been discussed so far, e.g., ." CREATE FOO" EVALUATE would create FOO
>
>No, that binds "CREATE" at run-time, and may result in completely
>different behaviour than
>
>s" FOO" ['] create execute-parsing
>
>if a different CREATE is found at run-time, or if it is not found at
>all.  See <https://www.complang.tuwien.ac.at/forth/why-evaluate-is-bad>.

This doesn't matter much, because there is a death penalty on redefining
CREATE. Your system is no longer standard.

>
>- anton

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

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


#51189

From"Elizabeth D. Rather" <erather@forth.com>
Date2016-09-23 07:52 -1000
Message-ID<xe6dnRgqVdpn9njKnZ2dnUU7-VPNnZ2d@supernews.com>
In reply to#51184
On 9/23/16 12:06 AM, Lars Brinkhoff wrote:
> Gerry Jackson <gerry@jackson9000.fsnet.co.uk> writes:
>> But do we want to open the possibility of having dictionary names with
>> spaces? That would lead to inconsistencies because words such as FIND
>> and SEARCH-WORDLIST would, presumably, be able to find 'NAMES WITH
>> SPACES' in the dictionary but parsing words such as ', ['], POSTPONE,
>> SYNONYM etc and the interpreter couldn't.
>
> Sure, that would be a point of contention.  When I mentioned this
> before, I believe one or two people thought it was a bad idea to allow
> unrestricted names, and one that thought it was a good idea.
>
> I guess it comes down to whether you view the dictionary as strictly a
> symbol table for program identifiers, or if you want to be able to use
> it as a more generic hash table indexed by strings.
>

The dictionary *is* a symbol table for program identifiers. If you have 
a string-oriented application it's likely to have a lot of requirements 
that differ from the dictionary. "Words separated by spaces" has been a 
bedrock of Forth programming since 1970. We have EVALUATE and other 
words to manage phrases. Don't contaminate the system interpreter and 
compiler with unrelated requirements.

Cheers,
Elizabeth

-- 
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================

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


#51185

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2016-09-23 10:36 -0500
Message-ID<p9-dnfs_IuB31njKnZ2dnUU7-U2dnZ2d@supernews.com>
In reply to#51178
Lars Brinkhoff <lars.spam@nocrew.org> wrote:
> 
> I believe that EXECUTE-PARSING can't do everything POSTFIX and
> NEXTNAME can do.  (And vice versa of course, but that's more
> obvious.)  E.g. this definition is supposed to accept a string and
> make a new definition with that string as its name:
> 
>    : "CREATE ( a u -- ) ['] CREATE EXECUTE-PARSING ;
> 
> However, if my understanding of EXECUTE-PARSING is correct, this
> fails with strings that contain whitespace.

It does.  You mentioned this before, but did not explain why anyone
but the most extreme nit-picker would care.  I don't care because in
Forth words are space-delimited, so there would be no [reasonable] way
to use such a word.

Andrew.

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


#50889

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-12 13:55 +0200
Message-ID<nr6543$jdh$1@cherry.spenarnc.xs4all.nl>
In reply to#50876
In article <2016Sep12.094616@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>Alex Dowad <alexinbeijing@gmail.com> writes:
>>ANS Forth has CREATE, which reads a token from SOURCE and adds a word to the dictionary. But I can't find any word in the standard which takes a string and adds a new word to the dictionary.
>>
>>This seems to be a failure of orthogonality; CREATE combines the functionality of WORD with that of adding to the dictionary. If those operations were split out from CREATE, that would have provided greater flexibility.
>
>Yes.
>
>>Is there some clever way to get around this, while staying within the standard? Or is it something which can only be done with implementation-specific code?
>
>As others have pointer out, EXECUTE-PARSING will do it, and there is a
>standard implementation of it; the releases are found in the compat
>library: <http://theforth.net/package/compat>.
>
>Concerning defining words with names that cannot be provided by
>PARSE-NAME, such as a string containing a space: I don't that that can
>be done with the current standard, because the standard CREATE parses
>the name in the same way as PARSE-NAME (and typically it calls
>PARSE-NAME or WORD); however, Gforth provides NEXTNAME ( c-addr u -- ),
>and you can CREATE a word with a space as a name as follows:
>
>s"  " nextname create

It seems silly to have names with non-printable characters and such.
However there are useful applications.
In my non-gui IDE you can type a function key and then you're asked
to define it. (e.g. .S is popular). Next time you type it, its
escape-sequence is looked up in the dictionary and .S (e.g) is executed.

>- anton

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

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


#50893

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2016-09-12 15:01 +0200
Message-ID<86inu1l1a6.fsf@molnjunk.nocrew.org>
In reply to#50889
albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes:
> It seems silly to have names with non-printable characters and such.
> However there are useful applications.
> In my non-gui IDE you can type a function key and then you're asked
> to define it. (e.g. .S is popular). Next time you type it, its
> escape-sequence is looked up in the dictionary and .S (e.g) is executed.

Yes, I had something like that in mind.

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


#50905

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-09-12 17:29 +0000
Message-ID<2016Sep12.192956@mips.complang.tuwien.ac.at>
In reply to#50889
albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes:
>It seems silly to have names with non-printable characters and such.
>However there are useful applications.
>In my non-gui IDE you can type a function key and then you're asked
>to define it. (e.g. .S is popular). Next time you type it, its
>escape-sequence is looked up in the dictionary and .S (e.g) is executed.

Yes, Gforth also looks up the escape sequences in the dictionary.  To
do that, it uses a TABLE (a case-sensitive wordlist), and it defines
the escape sequences using NEXTNAME.  NEXTNAME is also useful for
using TABLEs as general lookup structures (like hashes in other
programming languages), exactly because with NEXTNAME one can use
arbitrary binary data as keys (including a single byte containing
$20).

So if somebody wants to propose NEXTNAME for standardization, maybe
they should propose TABLE along with it, as this considerably
increases the number of use cases.

- 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 2016: http://www.euroforth.org/ef16/

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


#50907

Fromalbert@cherry.spenarnc.xs4all.nl (Albert van der Horst)
Date2016-09-12 21:02 +0200
Message-ID<nr6u3g$mdv$1@cherry.spenarnc.xs4all.nl>
In reply to#50905
In article <2016Sep12.192956@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
<SNIP>
>So if somebody wants to propose NEXTNAME for standardization, maybe
>they should propose TABLE along with it, as this considerably
>increases the number of use cases.

My thoughts go in a totally different direction. The things that
are looked up by the Forth interpreter are sequence of address units
aka bytes. How they are printed becomes implementation defined,
as well as how they are keyed in.

No need for more words. At the same time we could get rid of
the SHOUTING FROM THE FORTRAN ERA.

>
>- anton

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

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


Page 4 of 5 — ← Prev page 1 2 3 [4] 5  Next page →

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


csiph-web