Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The speed of anything depends on the flow of everything.


devel / comp.lang.forth / Standard way to define new words in a word

SubjectAuthor
* Standard way to define new words in a wordshtps
+* Re: Standard way to define new words in a wordBrian Fox
|+* Re: Standard way to define new words in a worddxforth
||`* Re: Standard way to define new words in a wordminf...@arcor.de
|| `- Re: Standard way to define new words in a worddxforth
|`* Re: Standard way to define new words in a wordshtps
| `* Re: Standard way to define new words in a wordBrian Fox
|  `* Re: Standard way to define new words in a wordshtps
|   `- Re: Standard way to define new words in a wordBrian Fox
+* Re: Standard way to define new words in a wordminf...@arcor.de
|`- Re: Standard way to define new words in a wordnone
+* Re: Standard way to define new words in a wordAnton Ertl
|`* Re: Standard way to define new words in a wordshtps
| `- Re: Standard way to define new words in a wordAnton Ertl
+- Re: Standard way to define new words in a wordNN
`- Re: Standard way to define new words in a wordnone

1
Standard way to define new words in a word

<td0a7o$9mh$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!mWsS2jh2hiD+X09pBT2y+g.user.46.165.242.75.POSTED!not-for-mail
From: sht...@eclipso.de (shtps)
Newsgroups: comp.lang.forth
Subject: Standard way to define new words in a word
Date: Wed, 10 Aug 2022 15:01:44 +0200
Organization: Aioe.org NNTP Server
Message-ID: <td0a7o$9mh$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="9937"; posting-host="mWsS2jh2hiD+X09pBT2y+g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: shtps - Wed, 10 Aug 2022 13:01 UTC

Hi, I'm quite new to Forth and I'm hoping I'll find some help here with
my Forth related questions.

How do I define new words within a word in standard Forth?

One way seems to be with evaluate:

: myword s" : newword 1 2 ; " evaluate s" : anotherword + ;" evaluate ;
newword anotherword .s

I've tested this with gforth and it works, but is this standard? How
would I do this without evaluate, but still be standard forth, if at all
possible?

Re: Standard way to define new words in a word

<35e7557b-79a8-4b9c-9a2d-240199a73485n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:11ca:b0:342:e8bb:ecca with SMTP id n10-20020a05622a11ca00b00342e8bbeccamr19924822qtk.11.1660138203091;
Wed, 10 Aug 2022 06:30:03 -0700 (PDT)
X-Received: by 2002:ac8:4e41:0:b0:343:5c49:951a with SMTP id
e1-20020ac84e41000000b003435c49951amr1601703qtw.25.1660138202882; Wed, 10 Aug
2022 06:30:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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: Wed, 10 Aug 2022 06:30:02 -0700 (PDT)
In-Reply-To: <td0a7o$9mh$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=99.242.210.36; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 99.242.210.36
References: <td0a7o$9mh$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <35e7557b-79a8-4b9c-9a2d-240199a73485n@googlegroups.com>
Subject: Re: Standard way to define new words in a word
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Wed, 10 Aug 2022 13:30:03 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1777
 by: Brian Fox - Wed, 10 Aug 2022 13:30 UTC

On Wednesday, August 10, 2022 at 9:02:08 AM UTC-4, shtps wrote:
> Hi, I'm quite new to Forth and I'm hoping I'll find some help here with
> my Forth related questions.
>
> How do I define new words within a word in standard Forth?
>
> One way seems to be with evaluate:
>
> : myword s" : newword 1 2 ; " evaluate s" : anotherword + ;" evaluate ;
> newword anotherword .s
>
> I've tested this with gforth and it works, but is this standard? How
> would I do this without evaluate, but still be standard forth, if at all
> possible?

I don't believe the standard provides a way to do this but I am not
an expert.

I am curious about your application/need for this.

Re: Standard way to define new words in a word

<106cb333-5705-4378-8738-442dcae4ce7bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5e14:0:b0:31f:4280:8d93 with SMTP id h20-20020ac85e14000000b0031f42808d93mr23765868qtx.36.1660139096715;
Wed, 10 Aug 2022 06:44:56 -0700 (PDT)
X-Received: by 2002:a05:622a:1194:b0:31f:3909:4e66 with SMTP id
m20-20020a05622a119400b0031f39094e66mr24478417qtk.305.1660139096493; Wed, 10
Aug 2022 06:44:56 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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: Wed, 10 Aug 2022 06:44:56 -0700 (PDT)
In-Reply-To: <td0a7o$9mh$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f27:a8a7:c196:cf33:48c0:df67;
posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f27:a8a7:c196:cf33:48c0:df67
References: <td0a7o$9mh$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <106cb333-5705-4378-8738-442dcae4ce7bn@googlegroups.com>
Subject: Re: Standard way to define new words in a word
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 10 Aug 2022 13:44:56 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1812
 by: minf...@arcor.de - Wed, 10 Aug 2022 13:44 UTC

shtps schrieb am Mittwoch, 10. August 2022 um 15:02:08 UTC+2:
> Hi, I'm quite new to Forth and I'm hoping I'll find some help here with
> my Forth related questions.
>
> How do I define new words within a word in standard Forth?
>
> One way seems to be with evaluate:
>
> : myword s" : newword 1 2 ; " evaluate s" : anotherword + ;" evaluate ;
> newword anotherword .s
>
> I've tested this with gforth and it works, but is this standard? How
> would I do this without evaluate, but still be standard forth, if at all
> possible?

Modern Forths support nonames within other words, called quotations. See
http://www.forth200x.org/quotations.txt

Re: Standard way to define new words in a word

<2022Aug10.155542@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Standard way to define new words in a word
Date: Wed, 10 Aug 2022 13:55:42 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 52
Message-ID: <2022Aug10.155542@mips.complang.tuwien.ac.at>
References: <td0a7o$9mh$1@gioia.aioe.org>
Injection-Info: reader01.eternal-september.org; posting-host="53d96fb8d0c2a29d03ada0a092de88d5";
logging-data="1960234"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hfBVfMiyBjnqvQ1GE7Dx3"
Cancel-Lock: sha1:z1fJ9OsjnQU5+ZS6NjRQYLwG4no=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 10 Aug 2022 13:55 UTC

shtps <shtps@eclipso.de> writes:
>: myword s" : newword 1 2 ; " evaluate s" : anotherword + ;" evaluate ;
>newword anotherword .s
>
>I've tested this with gforth and it works, but is this standard?

You have to call MYWORD before you can use NEWWORD and ANOTHERWORD,
otherwise it does not work (not in Gforth, either). But apart from
that it is standard. However, EVALUATE uses a lot of the environment
when MYWORD is called, so I don't recommend using it for this purpose.
See <http://www.complang.tuwien.ac.at/forth/why-evaluate-is-bad>.

>How
>would I do this without evaluate, but still be standard forth, if at all
>possible?

: myword
: 1 postpone literal 2 postpone literal postpone ;
: postpone + postpone ;
; myword newword anotherword
newword anotherword .s

Note that in this variant the names of the two words are provided at
MYWORD run-time. If you want to provide them at compile-time, one way
to do it is to use EXECUTE-PARSING (defined in standard Forth in
<http://www.complang.tuwien.ac.at/forth/compat/execute-parsing.fs>,
but present in Gforth out of the box):

: myword
s" newword" ['] : execute-parsing
1 postpone literal 2 postpone literal postpone ;
s" anotherword" ['] : execute-parsing postpone + postpone ;
; myword
newword anotherword .s

There's a shorthand for all the POSTPONEs (and LITERALs) in Gforth:

: myword
s" newword" ['] : execute-parsing ]] 1 2 ; [[
s" anotherword" ['] : execute-parsing ]] + ; [[
; myword
newword anotherword .s

- 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: Standard way to define new words in a word

<6a9d65c9-585e-4013-8426-67cb9f13dc0cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:5c91:0:b0:31f:2385:3633 with SMTP id r17-20020ac85c91000000b0031f23853633mr24689917qta.674.1660145034256;
Wed, 10 Aug 2022 08:23:54 -0700 (PDT)
X-Received: by 2002:a05:620a:1981:b0:6b5:cccf:62e1 with SMTP id
bm1-20020a05620a198100b006b5cccf62e1mr20571781qkb.376.1660145034055; Wed, 10
Aug 2022 08:23:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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: Wed, 10 Aug 2022 08:23:53 -0700 (PDT)
In-Reply-To: <td0a7o$9mh$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23c5:6f05:3a01:605d:6245:ed9c:efad;
posting-account=9A5f7goAAAD_QfJPZnlK3Xq_UhzYjdP-
NNTP-Posting-Host: 2a00:23c5:6f05:3a01:605d:6245:ed9c:efad
References: <td0a7o$9mh$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6a9d65c9-585e-4013-8426-67cb9f13dc0cn@googlegroups.com>
Subject: Re: Standard way to define new words in a word
From: november...@gmail.com (NN)
Injection-Date: Wed, 10 Aug 2022 15:23:54 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1865
 by: NN - Wed, 10 Aug 2022 15:23 UTC

On Wednesday, 10 August 2022 at 14:02:08 UTC+1, shtps wrote:
> Hi, I'm quite new to Forth and I'm hoping I'll find some help here with
> my Forth related questions.
>
> How do I define new words within a word in standard Forth?

Forth is flat. You cannot nest words like you can nest functions in say Pascal.

>
> One way seems to be with evaluate:
>
> : myword s" : newword 1 2 ; " evaluate s" : anotherword + ;" evaluate ;
> newword anotherword .s
>
> I've tested this with gforth and it works, but is this standard? How
> would I do this without evaluate, but still be standard forth, if at all
> possible?

: newword 1 2 ;
: anotherword + ;
: myword newword anotherword ;
myword .s

Re: Standard way to define new words in a word

<td0p86$1253$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Standard way to define new words in a word
Date: Thu, 11 Aug 2022 03:17:58 +1000
Organization: Aioe.org NNTP Server
Message-ID: <td0p86$1253$1@gioia.aioe.org>
References: <td0a7o$9mh$1@gioia.aioe.org>
<35e7557b-79a8-4b9c-9a2d-240199a73485n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="34979"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.2
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Wed, 10 Aug 2022 17:17 UTC

On 10/08/2022 23:30, Brian Fox wrote:
>
> I am curious about your application/need for this.

Pretty sure I never has such thoughts when I was beginning forth.
Must be the new generation :)

Re: Standard way to define new words in a word

<187131f7-07b6-42c5-8a23-d8bfa3c6c783n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:230e:b0:343:616b:1f88 with SMTP id ck14-20020a05622a230e00b00343616b1f88mr1436276qtb.457.1660155830530;
Wed, 10 Aug 2022 11:23:50 -0700 (PDT)
X-Received: by 2002:ac8:7fc4:0:b0:342:86e2:6a28 with SMTP id
b4-20020ac87fc4000000b0034286e26a28mr22867868qtk.517.1660155830402; Wed, 10
Aug 2022 11:23:50 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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: Wed, 10 Aug 2022 11:23:50 -0700 (PDT)
In-Reply-To: <td0p86$1253$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=87.157.100.114; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 87.157.100.114
References: <td0a7o$9mh$1@gioia.aioe.org> <35e7557b-79a8-4b9c-9a2d-240199a73485n@googlegroups.com>
<td0p86$1253$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <187131f7-07b6-42c5-8a23-d8bfa3c6c783n@googlegroups.com>
Subject: Re: Standard way to define new words in a word
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Wed, 10 Aug 2022 18:23:50 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1584
 by: minf...@arcor.de - Wed, 10 Aug 2022 18:23 UTC

dxforth schrieb am Mittwoch, 10. August 2022 um 19:18:01 UTC+2:
> On 10/08/2022 23:30, Brian Fox wrote:
> >
> > I am curious about your application/need for this.
> Pretty sure I never has such thoughts when I was beginning forth.
> Must be the new generation :)

In those antiquish days a closure was a closure. ;-)

Now for those youngish ones a closure opens new ways of programming.

Re: Standard way to define new words in a word

<td0u2b$12pa$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!mWsS2jh2hiD+X09pBT2y+g.user.46.165.242.75.POSTED!not-for-mail
From: sht...@eclipso.de (shtps)
Newsgroups: comp.lang.forth
Subject: Re: Standard way to define new words in a word
Date: Wed, 10 Aug 2022 20:40:10 +0200
Organization: Aioe.org NNTP Server
Message-ID: <td0u2b$12pa$1@gioia.aioe.org>
References: <td0a7o$9mh$1@gioia.aioe.org>
<2022Aug10.155542@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="35626"; posting-host="mWsS2jh2hiD+X09pBT2y+g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: shtps - Wed, 10 Aug 2022 18:40 UTC

On 8/10/22 15:55, Anton Ertl wrote:
> You have to call MYWORD before you can use NEWWORD and ANOTHERWORD,
> otherwise it does not work (not in Gforth, either).

Sorry, yes, I have done that but forgot to write it here.

> However, EVALUATE uses a lot of the environment
> when MYWORD is called, so I don't recommend using it for this purpose.
> See <http://www.complang.tuwien.ac.at/forth/why-evaluate-is-bad>.

It was not my intention to use the environment when MYWORD is called,
but when it is compiled. I did not consider this and I'll keep this in
mind when considering the use of EVALUATE in the future.

> If you want to provide them at compile-time, one way
> to do it is to use EXECUTE-PARSING (defined in standard Forth in
> <http://www.complang.tuwien.ac.at/forth/compat/execute-parsing.fs>,
> but present in Gforth out of the box):
>
> : myword
> s" newword" ['] : execute-parsing
> 1 postpone literal 2 postpone literal postpone ;
> s" anotherword" ['] : execute-parsing postpone + postpone ;
> ;
> myword
> newword anotherword .s

This is exactly what I was attempting to do but didn't know about
EXECUTE-PARSING or how to put it all together.

> There's a shorthand for all the POSTPONEs (and LITERALs) in Gforth:
>
> : myword
> s" newword" ['] : execute-parsing ]] 1 2 ; [[
> s" anotherword" ['] : execute-parsing ]] + ; [[

I like this syntax sugar. I assume I can use the files in the
<https://www.complang.tuwien.ac.at/forth/compat/> directory for
compatibility with standard Forth? And I see that macros.fs is for this.

Thank you very much for taking the time to write up such elaborate
explanations! It helps a lot!

Re: Standard way to define new words in a word

<td0uba$1776$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!mWsS2jh2hiD+X09pBT2y+g.user.46.165.242.75.POSTED!not-for-mail
From: sht...@eclipso.de (shtps)
Newsgroups: comp.lang.forth
Subject: Re: Standard way to define new words in a word
Date: Wed, 10 Aug 2022 20:44:58 +0200
Organization: Aioe.org NNTP Server
Message-ID: <td0uba$1776$1@gioia.aioe.org>
References: <td0a7o$9mh$1@gioia.aioe.org>
<35e7557b-79a8-4b9c-9a2d-240199a73485n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="40166"; posting-host="mWsS2jh2hiD+X09pBT2y+g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: shtps - Wed, 10 Aug 2022 18:44 UTC

On 8/10/22 15:30, Brian Fox wrote:
> I am curious about your application/need for this.

I'm experimenting around with creating a game in Forth and I'm writing a
domain specific language that generates the words I need.

Normally, if I would just be writing a binding generator for some API
for example, I would write a Forth program that generates the bindings
and writes them to a file (Forth source code) and then include that in
my application at the very top. However the code generated in this case
is so specific to my game/application that simply generating the words
in Forth itself is preferable, without having to deal with source code
or files at all, and instead generate the words directly.

Re: Standard way to define new words in a word

<2022Aug10.232040@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Standard way to define new words in a word
Date: Wed, 10 Aug 2022 21:20:40 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 31
Message-ID: <2022Aug10.232040@mips.complang.tuwien.ac.at>
References: <td0a7o$9mh$1@gioia.aioe.org> <2022Aug10.155542@mips.complang.tuwien.ac.at> <td0u2b$12pa$1@gioia.aioe.org>
Injection-Info: reader01.eternal-september.org; posting-host="53d96fb8d0c2a29d03ada0a092de88d5";
logging-data="2042683"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qfVAMiW+dXU3TKGjwDyUh"
Cancel-Lock: sha1:2OBFyZ/WVEHDy1hJBSfZudMQFMI=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 10 Aug 2022 21:20 UTC

shtps <shtps@eclipso.de> writes:
>On 8/10/22 15:55, Anton Ertl wrote:
>> There's a shorthand for all the POSTPONEs (and LITERALs) in Gforth:
>>
>> : myword
>> s" newword" ['] : execute-parsing ]] 1 2 ; [[
>> s" anotherword" ['] : execute-parsing ]] + ; [[
>
>I like this syntax sugar. I assume I can use the files in the
><https://www.complang.tuwien.ac.at/forth/compat/> directory for
>compatibility with standard Forth?

Yes. You can get them in one package as
<http://www.complang.tuwien.ac.at/forth/compat.zip>

>And I see that macros.fs is for this.

Yes, but depending on the Forth system you may have to write

2 1 ]] literal literal [[

instead of

]] 1 2 [[

- 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: Standard way to define new words in a word

<e9fbb900-867f-4b95-9415-e933ee0abd37n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:620a:4442:b0:6b2:844e:ee67 with SMTP id w2-20020a05620a444200b006b2844eee67mr22769320qkp.625.1660180088422;
Wed, 10 Aug 2022 18:08:08 -0700 (PDT)
X-Received: by 2002:a05:6214:c85:b0:476:ef65:5495 with SMTP id
r5-20020a0562140c8500b00476ef655495mr25509710qvr.88.1660180088260; Wed, 10
Aug 2022 18:08:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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: Wed, 10 Aug 2022 18:08:08 -0700 (PDT)
In-Reply-To: <td0uba$1776$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2607:fea8:2a60:9ae:467:f691:b073:ca00;
posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 2607:fea8:2a60:9ae:467:f691:b073:ca00
References: <td0a7o$9mh$1@gioia.aioe.org> <35e7557b-79a8-4b9c-9a2d-240199a73485n@googlegroups.com>
<td0uba$1776$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e9fbb900-867f-4b95-9415-e933ee0abd37n@googlegroups.com>
Subject: Re: Standard way to define new words in a word
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Thu, 11 Aug 2022 01:08:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2314
 by: Brian Fox - Thu, 11 Aug 2022 01:08 UTC

On Wednesday, August 10, 2022 at 2:45:00 PM UTC-4, shtps wrote:
> On 8/10/22 15:30, Brian Fox wrote:
> > I am curious about your application/need for this.
> I'm experimenting around with creating a game in Forth and I'm writing a
> domain specific language that generates the words I need.
>
> Normally, if I would just be writing a binding generator for some API
> for example, I would write a Forth program that generates the bindings
> and writes them to a file (Forth source code) and then include that in
> my application at the very top. However the code generated in this case
> is so specific to my game/application that simply generating the words
> in Forth itself is preferable, without having to deal with source code
> or files at all, and instead generate the words directly.

So I guess the DSL is dynamic inside the game? (makes my old head spin)
Perhaps the player defines the meanings of words as they play?

I am with DxForth. I have never thought about this kind of thing.
Perhaps a dumb question but would DEFER words do this job?

Re: Standard way to define new words in a word

<td21v5$bjv$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Standard way to define new words in a word
Date: Thu, 11 Aug 2022 14:52:53 +1000
Organization: Aioe.org NNTP Server
Message-ID: <td21v5$bjv$1@gioia.aioe.org>
References: <td0a7o$9mh$1@gioia.aioe.org>
<35e7557b-79a8-4b9c-9a2d-240199a73485n@googlegroups.com>
<td0p86$1253$1@gioia.aioe.org>
<187131f7-07b6-42c5-8a23-d8bfa3c6c783n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="11903"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.1.2
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Thu, 11 Aug 2022 04:52 UTC

On 11/08/2022 04:23, minf...@arcor.de wrote:
> dxforth schrieb am Mittwoch, 10. August 2022 um 19:18:01 UTC+2:
>> On 10/08/2022 23:30, Brian Fox wrote:
>>>
>>> I am curious about your application/need for this.
>> Pretty sure I never has such thoughts when I was beginning forth.
>> Must be the new generation :)
>
> In those antiquish days a closure was a closure. ;-)
>
> Now for those youngish ones a closure opens new ways of programming.

It may be youngish ones are simply accepting of what older ones are
offering as solutions - instead of examining it for themselves, which
takes effort and discrimination.

Re: Standard way to define new words in a word

<tdajc5$1t3o$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!Ocer4eygmu/tDLDYOWpnIw.user.46.165.242.75.POSTED!not-for-mail
From: sht...@eclipso.de (shtps)
Newsgroups: comp.lang.forth
Subject: Re: Standard way to define new words in a word
Date: Sun, 14 Aug 2022 12:39:00 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tdajc5$1t3o$1@gioia.aioe.org>
References: <td0a7o$9mh$1@gioia.aioe.org>
<35e7557b-79a8-4b9c-9a2d-240199a73485n@googlegroups.com>
<td0uba$1776$1@gioia.aioe.org>
<e9fbb900-867f-4b95-9415-e933ee0abd37n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62584"; posting-host="Ocer4eygmu/tDLDYOWpnIw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: shtps - Sun, 14 Aug 2022 10:39 UTC

On 8/11/22 03:08, Brian Fox wrote:
> So I guess the DSL is dynamic inside the game? (makes my old head spin)
> Perhaps the player defines the meanings of words as they play?

The idea is to create a simple way to define higher level concepts for
the engine. For my game I'm going to be using an entity component
system, as I already have experience with writing games in it and which
gives the game a lot of flexibility, but it also comes with the
necessary "bookkeeping".

Writing games takes a lot of time if you write everything from scratch,
so I'm currently just experimenting because I don't have the time needed
to devote myself to writing a game to completion.

> I am with DxForth. I have never thought about this kind of thing.
> Perhaps a dumb question but would DEFER words do this job?

In my case I could do the same with structs or something similar to it,
or even just aliasing really. It isn't even necessary to generate the
words in my case, I probably wont stick with it.

I have a C# background so maybe that's where I got the idea from:
<https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview>

Re: Standard way to define new words in a word

<0e9d4626-5920-45ed-90c2-01830f6cf3bcn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:58ca:0:b0:344:5cbe:4c9a with SMTP id u10-20020ac858ca000000b003445cbe4c9amr1116656qta.36.1660487235768;
Sun, 14 Aug 2022 07:27:15 -0700 (PDT)
X-Received: by 2002:a05:6214:76b:b0:476:5c98:2a55 with SMTP id
f11-20020a056214076b00b004765c982a55mr10539369qvz.70.1660487235605; Sun, 14
Aug 2022 07:27:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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, 14 Aug 2022 07:27:15 -0700 (PDT)
In-Reply-To: <tdajc5$1t3o$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=99.242.210.36; posting-account=2z7GawoAAADc70p5SM5AbaCyzjLblS3g
NNTP-Posting-Host: 99.242.210.36
References: <td0a7o$9mh$1@gioia.aioe.org> <35e7557b-79a8-4b9c-9a2d-240199a73485n@googlegroups.com>
<td0uba$1776$1@gioia.aioe.org> <e9fbb900-867f-4b95-9415-e933ee0abd37n@googlegroups.com>
<tdajc5$1t3o$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0e9d4626-5920-45ed-90c2-01830f6cf3bcn@googlegroups.com>
Subject: Re: Standard way to define new words in a word
From: brian....@brianfox.ca (Brian Fox)
Injection-Date: Sun, 14 Aug 2022 14:27:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2912
 by: Brian Fox - Sun, 14 Aug 2022 14:27 UTC

On Sunday, August 14, 2022 at 6:39:03 AM UTC-4, shtps wrote:
> On 8/11/22 03:08, Brian Fox wrote:
> > So I guess the DSL is dynamic inside the game? (makes my old head spin)
> > Perhaps the player defines the meanings of words as they play?
> The idea is to create a simple way to define higher level concepts for
> the engine. For my game I'm going to be using an entity component
> system, as I already have experience with writing games in it and which
> gives the game a lot of flexibility, but it also comes with the
> necessary "bookkeeping".
>
> Writing games takes a lot of time if you write everything from scratch,
> so I'm currently just experimenting because I don't have the time needed
> to devote myself to writing a game to completion.
> > I am with DxForth. I have never thought about this kind of thing.
> > Perhaps a dumb question but would DEFER words do this job?
> In my case I could do the same with structs or something similar to it,
> or even just aliasing really. It isn't even necessary to generate the
> words in my case, I probably wont stick with it.
>
> I have a C# background so maybe that's where I got the idea from:
> <https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview>

I have not read the entire source generator article but I wonder if Forth already
solves this because the interpreter is running while your are compiling source code.

Forth can read source and interpret parts of it while compiling other parts.

I may misunderstand this entirely but you may be trying to solve a problem that you
don't need to solve. ? :-)

Re: Standard way to define new words in a word

<nnd$50117e9a$44447097@d99c0a187bb73dc3>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <td0a7o$9mh$1@gioia.aioe.org>
Subject: Re: Standard way to define new words in a word
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$50117e9a$44447097@d99c0a187bb73dc3>
Organization: KPN B.V.
Date: Tue, 16 Aug 2022 22:34:53 +0200
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!feeder.usenetexpress.com!tr1.eu1.usenetexpress.com!94.232.112.245.MISMATCH!feed.abavia.com!abe005.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 58
Injection-Date: Tue, 16 Aug 2022 22:34:53 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: none - Tue, 16 Aug 2022 20:34 UTC

In article <td0a7o$9mh$1@gioia.aioe.org>, shtps <shtps@eclipso.de> wrote:
>Hi, I'm quite new to Forth and I'm hoping I'll find some help here with
>my Forth related questions.
>
>How do I define new words within a word in standard Forth?

: aap ": hello 1234 . ; " EVALUATE ;

aap
OK
hello
1234 OK

Note:
If you have an old fashioned Forth without denotations (recognizers)
you have to do
: aap S" : hello 1234 . ; " EVALUATE ;

If you are able to place double quotes in a string (as per ciforth)
a more canonical example would be. (ciforth shows the most recently
words last, contrary to most Forths)

AMDX86 ciforth 5.4.0
OK
: aap ": hello ""hello cruel world!"" TYPE CR ; " EVALUATE ;
OK
WORDS
....
BYE LIST INDEX .S ENVIRONMENT? .SIGNON TASK aap OK
aap
WORDS
....
BYE LIST INDEX .S ENVIRONMENT? .SIGNON TASK aap hello OK
hello
hello cruel world!
OK

>One way seems to be with evaluate:
Right. The only game in town, IMO.

>I've tested this with gforth and it works, but is this standard? How
>would I do this without evaluate, but still be standard forth, if at all
>possible?

EVALUATE is in CORE. There are people who content that using it is
not politically correct. Listen to them and you land in a snake pit
full POSTPONE's and new features that are not guaranteed to work
everywhere. Your choice.

Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Re: Standard way to define new words in a word

<nnd$0f97a6b8$53af2f35@7252c224f5d419d8>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <td0a7o$9mh$1@gioia.aioe.org> <106cb333-5705-4378-8738-442dcae4ce7bn@googlegroups.com>
Subject: Re: Standard way to define new words in a word
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: alb...@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$0f97a6b8$53af2f35@7252c224f5d419d8>
Organization: KPN B.V.
Date: Thu, 18 Aug 2022 13:20:38 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe006.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 32
Injection-Date: Thu, 18 Aug 2022 13:20:38 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1960
 by: none - Thu, 18 Aug 2022 11:20 UTC

In article <106cb333-5705-4378-8738-442dcae4ce7bn@googlegroups.com>,
minf...@arcor.de <minforth@arcor.de> wrote:
>shtps schrieb am Mittwoch, 10. August 2022 um 15:02:08 UTC+2:
>> Hi, I'm quite new to Forth and I'm hoping I'll find some help here with
>> my Forth related questions.
>>
>> How do I define new words within a word in standard Forth?
>>
>> One way seems to be with evaluate:
>>
>> : myword s" : newword 1 2 ; " evaluate s" : anotherword + ;" evaluate ;
>> newword anotherword .s
>>
>> I've tested this with gforth and it works, but is this standard? How
>> would I do this without evaluate, but still be standard forth, if at all
>> possible?
>
>Modern Forths support nonames within other words, called quotations. See
>http://www.forth200x.org/quotations.txt

Note that this is not an answer to the question. "define" means adding
words to the dictionary.
You answered the question: how can generate an execution token within a
definition.

Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor