Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The absence of labels [in ECL] is probably a good thing. -- T. Cheatham


devel / comp.lang.forth / Re: Executing words from generated text

SubjectAuthor
* Executing words from generated textVan Kichline
+* Re: Executing words from generated textminforth
|`* Re: Executing words from generated textminforth
| `- Re: Executing words from generated textNN
+- Re: Executing words from generated textNN
`* Re: Executing words from generated textAnton Ertl
 `- Re: Executing words from generated textVan Kichline

1
Executing words from generated text

<9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23030&group=comp.lang.forth#23030

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:31a7:b0:745:90a0:613e with SMTP id bi39-20020a05620a31a700b0074590a0613emr2050726qkb.14.1679875686305;
Sun, 26 Mar 2023 17:08:06 -0700 (PDT)
X-Received: by 2002:a05:6214:3189:b0:56b:ed36:ffb with SMTP id
lb9-20020a056214318900b0056bed360ffbmr3521430qvb.1.1679875686023; Sun, 26 Mar
2023 17:08:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 26 Mar 2023 17:08:05 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=50.46.219.106; posting-account=VRZdRQoAAAByg2veNn4xonsritzF12hS
NNTP-Posting-Host: 50.46.219.106
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com>
Subject: Executing words from generated text
From: vkichl...@gmail.com (Van Kichline)
Injection-Date: Mon, 27 Mar 2023 00:08:06 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1893
 by: Van Kichline - Mon, 27 Mar 2023 00:08 UTC

I am a Forth novice writing an application with many fixed text strings of widely differing lengths, indexed by two dimensions (with several additional attributes, like title and date.) I am currently using gForth.
I plan to create about 600 words like:
Group1Subgroup7Title ( -- caddr len ) S" A Subgroup Title" ;
But my question is: how can I programmatically execute a word from a string I've generated within another word? It seems like I need to put the word in the input buffer and call parse-word, but I haven't discovered how to do that. For example:
: PrintTitle ( group sub -- )
make-subgroup-title \ consumes group & sub, returns caddr and len or cstring
somehow-invoke-the-word-that-text-represents \ returns caddr len
type ;
I can write make-subgroup-title, but do not understand how to write somehow-invoke-the-word-that-text-represents.
Thanks for your time!

Re: Executing words from generated text

<e040c7df-2b9e-46db-b9aa-93827fbfcc95n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23032&group=comp.lang.forth#23032

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:2119:b0:746:8cfa:1934 with SMTP id l25-20020a05620a211900b007468cfa1934mr1907805qkl.4.1679895892300;
Sun, 26 Mar 2023 22:44:52 -0700 (PDT)
X-Received: by 2002:a05:622a:15c1:b0:3bf:db9d:843 with SMTP id
d1-20020a05622a15c100b003bfdb9d0843mr4002695qty.7.1679895892074; Sun, 26 Mar
2023 22:44:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 26 Mar 2023 22:44:51 -0700 (PDT)
In-Reply-To: <9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f0d:70dd:bc4b:2dd1:c131:c178;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f0d:70dd:bc4b:2dd1:c131:c178
References: <9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e040c7df-2b9e-46db-b9aa-93827fbfcc95n@googlegroups.com>
Subject: Re: Executing words from generated text
From: minfo...@arcor.de (minforth)
Injection-Date: Mon, 27 Mar 2023 05:44:52 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2288
 by: minforth - Mon, 27 Mar 2023 05:44 UTC

Van Kichline schrieb am Montag, 27. März 2023 um 02:08:07 UTC+2:
> I am a Forth novice writing an application with many fixed text strings of widely differing lengths, indexed by two dimensions (with several additional attributes, like title and date.) I am currently using gForth.
> I plan to create about 600 words like:
> Group1Subgroup7Title ( -- caddr len ) S" A Subgroup Title" ;
> But my question is: how can I programmatically execute a word from a string I've generated within another word? It seems like I need to put the word in the input buffer and call parse-word, but I haven't discovered how to do that. For example:
> : PrintTitle ( group sub -- )
> make-subgroup-title \ consumes group & sub, returns caddr and len or cstring
> somehow-invoke-the-word-that-text-represents \ returns caddr len
> type ;
> I can write make-subgroup-title, but do not understand how to write somehow-invoke-the-word-that-text-represents.
> Thanks for your time!

Try something along PARSE-NAME EVALUATE

Re: Executing words from generated text

<299c91c5-090e-4a6f-9b5a-34e9cc6bb03dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23034&group=comp.lang.forth#23034

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:174e:b0:5a8:6ec7:b5ef with SMTP id dc14-20020a056214174e00b005a86ec7b5efmr1966661qvb.9.1679897532592;
Sun, 26 Mar 2023 23:12:12 -0700 (PDT)
X-Received: by 2002:a37:ab14:0:b0:748:6c01:70ee with SMTP id
u20-20020a37ab14000000b007486c0170eemr527219qke.0.1679897532395; Sun, 26 Mar
2023 23:12:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 26 Mar 2023 23:12:12 -0700 (PDT)
In-Reply-To: <e040c7df-2b9e-46db-b9aa-93827fbfcc95n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f0d:70dd:bc4b:2dd1:c131:c178;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f0d:70dd:bc4b:2dd1:c131:c178
References: <9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com> <e040c7df-2b9e-46db-b9aa-93827fbfcc95n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <299c91c5-090e-4a6f-9b5a-34e9cc6bb03dn@googlegroups.com>
Subject: Re: Executing words from generated text
From: minfo...@arcor.de (minforth)
Injection-Date: Mon, 27 Mar 2023 06:12:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2781
 by: minforth - Mon, 27 Mar 2023 06:12 UTC

minforth schrieb am Montag, 27. März 2023 um 07:44:53 UTC+2:
> Van Kichline schrieb am Montag, 27. März 2023 um 02:08:07 UTC+2:
> > I am a Forth novice writing an application with many fixed text strings of widely differing lengths, indexed by two dimensions (with several additional attributes, like title and date.) I am currently using gForth.
> > I plan to create about 600 words like:
> > Group1Subgroup7Title ( -- caddr len ) S" A Subgroup Title" ;
> > But my question is: how can I programmatically execute a word from a string I've generated within another word? It seems like I need to put the word in the input buffer and call parse-word, but I haven't discovered how to do that. For example:
> > : PrintTitle ( group sub -- )
> > make-subgroup-title \ consumes group & sub, returns caddr and len or cstring
> > somehow-invoke-the-word-that-text-represents \ returns caddr len
> > type ;
> > I can write make-subgroup-title, but do not understand how to write somehow-invoke-the-word-that-text-represents.
> > Thanks for your time!
> Try something along PARSE-NAME EVALUATE

Another helper word to separate names within non-empty(!) strings:

: PARSE-STRING ( a u -- a' u' ap up )
BEGIN over c@ bl = WHILE 1 /string REPEAT
over >r
BEGIN over c@ bl <> WHILE 1 /string REPEAT
over r@ - r> swap ;
\ test
s" fair may 2023 "
parse-string cr type
parse-string cr type
parse-string cr type

Re: Executing words from generated text

<202cd44a-244e-4e6e-8bf3-c9e1dcc6da05n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23040&group=comp.lang.forth#23040

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:57c2:0:b0:3e3:db7d:da45 with SMTP id w2-20020ac857c2000000b003e3db7dda45mr4337382qta.2.1679917429998;
Mon, 27 Mar 2023 04:43:49 -0700 (PDT)
X-Received: by 2002:a05:620a:22a2:b0:746:8b1a:1e4e with SMTP id
p2-20020a05620a22a200b007468b1a1e4emr2648112qkh.8.1679917429813; Mon, 27 Mar
2023 04:43:49 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 27 Mar 2023 04:43:49 -0700 (PDT)
In-Reply-To: <9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.212.136; posting-account=9A5f7goAAAD_QfJPZnlK3Xq_UhzYjdP-
NNTP-Posting-Host: 92.40.212.136
References: <9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <202cd44a-244e-4e6e-8bf3-c9e1dcc6da05n@googlegroups.com>
Subject: Re: Executing words from generated text
From: november...@gmail.com (NN)
Injection-Date: Mon, 27 Mar 2023 11:43:49 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2463
 by: NN - Mon, 27 Mar 2023 11:43 UTC

On Monday, 27 March 2023 at 01:08:07 UTC+1, Van Kichline wrote:
> I am a Forth novice writing an application with many fixed text strings of widely differing lengths, indexed by two dimensions (with several additional attributes, like title and date.) I am currently using gForth.
> I plan to create about 600 words like:
> Group1Subgroup7Title ( -- caddr len ) S" A Subgroup Title" ;
> But my question is: how can I programmatically execute a word from a string I've generated within another word? It seems like I need to put the word in the input buffer and call parse-word, but I haven't discovered how to do that. For example:
> : PrintTitle ( group sub -- )
> make-subgroup-title \ consumes group & sub, returns caddr and len or cstring
> somehow-invoke-the-word-that-text-represents \ returns caddr len
> type ;
> I can write make-subgroup-title, but do not understand how to write somehow-invoke-the-word-that-text-represents.
> Thanks for your time!

(1) If you use evaluate it will make the string into a new buffer.

(2) You could also ' or ['] a word and execute the token.

(3) ( addr u ) is preferred over (cstring )
{ where cstring means counted string as opposed to a c-string ending in '\0' }

(4) 600 is a lot of words.
If your groups and subgroups are fixed you could do a vectored execution.

Re: Executing words from generated text

<698f2ff9-bd58-409d-adad-60924d8741b6n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23041&group=comp.lang.forth#23041

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:4e8e:0:b0:5de:4f60:6dc9 with SMTP id dy14-20020ad44e8e000000b005de4f606dc9mr1122678qvb.5.1679917640107;
Mon, 27 Mar 2023 04:47:20 -0700 (PDT)
X-Received: by 2002:a05:620a:25cb:b0:746:97a1:81c with SMTP id
y11-20020a05620a25cb00b0074697a1081cmr2674628qko.11.1679917639943; Mon, 27
Mar 2023 04:47:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 27 Mar 2023 04:47:19 -0700 (PDT)
In-Reply-To: <299c91c5-090e-4a6f-9b5a-34e9cc6bb03dn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.212.136; posting-account=9A5f7goAAAD_QfJPZnlK3Xq_UhzYjdP-
NNTP-Posting-Host: 92.40.212.136
References: <9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com>
<e040c7df-2b9e-46db-b9aa-93827fbfcc95n@googlegroups.com> <299c91c5-090e-4a6f-9b5a-34e9cc6bb03dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <698f2ff9-bd58-409d-adad-60924d8741b6n@googlegroups.com>
Subject: Re: Executing words from generated text
From: november...@gmail.com (NN)
Injection-Date: Mon, 27 Mar 2023 11:47:20 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3057
 by: NN - Mon, 27 Mar 2023 11:47 UTC

On Monday, 27 March 2023 at 07:12:13 UTC+1, minforth wrote:
> minforth schrieb am Montag, 27. März 2023 um 07:44:53 UTC+2:
> > Van Kichline schrieb am Montag, 27. März 2023 um 02:08:07 UTC+2:
> > > I am a Forth novice writing an application with many fixed text strings of widely differing lengths, indexed by two dimensions (with several additional attributes, like title and date.) I am currently using gForth.
> > > I plan to create about 600 words like:
> > > Group1Subgroup7Title ( -- caddr len ) S" A Subgroup Title" ;
> > > But my question is: how can I programmatically execute a word from a string I've generated within another word? It seems like I need to put the word in the input buffer and call parse-word, but I haven't discovered how to do that. For example:
> > > : PrintTitle ( group sub -- )
> > > make-subgroup-title \ consumes group & sub, returns caddr and len or cstring
> > > somehow-invoke-the-word-that-text-represents \ returns caddr len
> > > type ;
> > > I can write make-subgroup-title, but do not understand how to write somehow-invoke-the-word-that-text-represents.
> > > Thanks for your time!
> > Try something along PARSE-NAME EVALUATE
> Another helper word to separate names within non-empty(!) strings:
>
> : PARSE-STRING ( a u -- a' u' ap up )
> BEGIN over c@ bl = WHILE 1 /string REPEAT
> over >r
> BEGIN over c@ bl <> WHILE 1 /string REPEAT
> over r@ - r> swap ;
>
> \ test
> s" fair may 2023 "
> parse-string cr type
> parse-string cr type
> parse-string cr type

two thoughts...
(1) doesnt test for reaching the end of the line.
(2) SKIP and SCAN may not be standard but most forth have them

Re: Executing words from generated text

<2023Mar27.165904@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23045&group=comp.lang.forth#23045

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Executing words from generated text
Date: Mon, 27 Mar 2023 14:59:04 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 15
Message-ID: <2023Mar27.165904@mips.complang.tuwien.ac.at>
References: <9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com>
Injection-Info: dont-email.me; posting-host="77b2eeb8845f1d559013c2ced5a15326";
logging-data="3439077"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181XuxdVqZ9qud7u1ahLLub"
Cancel-Lock: sha1:90eB/U2n5YVcf3Thrbg1WTk8E1c=
X-newsreader: xrn 10.11
 by: Anton Ertl - Mon, 27 Mar 2023 14:59 UTC

Van Kichline <vkichline@gmail.com> writes:
>But my question is: how can I programmatically execute a word from a string I've generated within another word?

1) With SEARCH-WORDLIST and EXECUTE

2) With EVALUATE. Note that EVALUATE has some caveats, which may or
may not be relevant in your case
<http://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: https://forth-standard.org/
EuroForth 2022: https://euro.theforth.net

Re: Executing words from generated text

<ff87e1f9-0923-4191-911d-955b1b6226ban@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23046&group=comp.lang.forth#23046

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:1a24:b0:3d3:f7cf:1d4b with SMTP id f36-20020a05622a1a2400b003d3f7cf1d4bmr4823825qtb.2.1679940987899;
Mon, 27 Mar 2023 11:16:27 -0700 (PDT)
X-Received: by 2002:ac8:5a0a:0:b0:3de:a24b:c895 with SMTP id
n10-20020ac85a0a000000b003dea24bc895mr4633904qta.5.1679940987608; Mon, 27 Mar
2023 11:16:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 27 Mar 2023 11:16:27 -0700 (PDT)
In-Reply-To: <2023Mar27.165904@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=50.46.219.106; posting-account=VRZdRQoAAAByg2veNn4xonsritzF12hS
NNTP-Posting-Host: 50.46.219.106
References: <9f872c7d-cd85-40bf-8c89-37270d733c26n@googlegroups.com> <2023Mar27.165904@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ff87e1f9-0923-4191-911d-955b1b6226ban@googlegroups.com>
Subject: Re: Executing words from generated text
From: vkichl...@gmail.com (Van Kichline)
Injection-Date: Mon, 27 Mar 2023 18:16:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2953
 by: Van Kichline - Mon, 27 Mar 2023 18:16 UTC

On Monday, March 27, 2023 at 8:07:56 AM UTC-7, Anton Ertl wrote:
> Van Kichline <vkic...@gmail.com> writes:
> >But my question is: how can I programmatically execute a word from a string I've generated within another word?
> 1) With SEARCH-WORDLIST and EXECUTE
>
> 2) With EVALUATE. Note that EVALUATE has some caveats, which may or
> may not be relevant in your case
> <http://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: https://forth-standard.org/
> EuroForth 2022: https://euro.theforth.net
Thanks, all! Evaluate is what I was looking for. 'S" Group2Part3" evaluate type' selects one of many string generators, which I can select by building the word to evaluate.

Rushing ahead yesterday, I built index arrays (tick word comma (repeat)) to look up my words. My total string data comes to ~580 groups and ~80K of text. I believe the indexes add about 5K in 64 bit gForth and save between 3 and 12 evaluations per execution of my program.
The point of this exercise was to be heavy on data and data selection, lighter on calculation. I found two very different approaches; constructing words for querying the dictionary, or constructing array indexes. I imagine I can economize more by using anonymous definitions in the arrays.
I thought leveraging the dictionary for lookups would be a good strategy, but on the order of 1000 items indexes seem simple and efficient. Perhaps if indexes consumed too much of available RAM lookups would be preferable.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor