Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

FORTH IF HONK THEN


devel / comp.lang.forth / RFD: Static forward references

SubjectAuthor
* RFD: Static forward referencesBrad Eckert
+* Re: RFD: Static forward referencesHeinrich Hohl
|`- Re: RFD: Static forward referencesnone
+* Re: RFD: Static forward referencesAnton Ertl
|+- Re: RFD: Static forward referencesdxforth
|`* Re: RFD: Static forward referencesHeinrich Hohl
| +- Re: RFD: Static forward referencesjan Coombs
| +- Re: RFD: Static forward referencesdxforth
| `- Re: RFD: Static forward referencesAnton Ertl
+- Re: RFD: Static forward referencesnone
+* Re: RFD: Static forward referencesMarcel Hendrix
|`- Re: RFD: Static forward referencesdxforth
`* Re: RFD: Static forward referencesHans Bezemer
 `- Re: RFD: Static forward referencesdxforth

1
RFD: Static forward references

<aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24259&group=comp.lang.forth#24259

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:18f3:b0:63f:7a28:2abf with SMTP id ep19-20020a05621418f300b0063f7a282abfmr76787qvb.12.1691898201297;
Sat, 12 Aug 2023 20:43:21 -0700 (PDT)
X-Received: by 2002:a05:6a00:2e8f:b0:687:427c:1ad2 with SMTP id
fd15-20020a056a002e8f00b00687427c1ad2mr2675371pfb.1.1691898200697; Sat, 12
Aug 2023 20:43:20 -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: Sat, 12 Aug 2023 20:43:20 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=72.217.63.66; posting-account=6GCGIQoAAAAyO8IjR_VTwqiqLwx0Q_G8
NNTP-Posting-Host: 72.217.63.66
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
Subject: RFD: Static forward references
From: hwfwguy@gmail.com (Brad Eckert)
Injection-Date: Sun, 13 Aug 2023 03:43:21 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2245
 by: Brad Eckert - Sun, 13 Aug 2023 03:43 UTC

The usual way to handle forward references in Forth is to use DEFER and IS. The CORE EXT wordset includes some other goodies like ACTION-OF, DEFER!, and DEFER@.

This usage provides a kind of OOPless late binding. Dynamic forward references can be changed by DEFER!. What if all you want is a static forward reference? The overhead is a waste of resources.

I use LATER and RESOLVES:

LATER foo \ compiles a jump instruction with a blank address
: bar foo ... ;
:noname ( foo ) ; RESOLVES foo \ fills in the address

So, there are some points I would like to make about DEFER:

1. DEFER is used for two different things. The spirit of Forth is for words to do only one thing. It's overkill for the static case.

2. IS can be "smartened up", or overloaded the way TO is, but the complexification is anti-Forth even if you can make it work.

3. There could be better words to use than LATER and RESOLVES for static forward references. I have seen IST used, but we are not all German.

4. This is almost surely a matter of taste. I don't like to waste RAM and clock cycles. There are plenty of those to burn these days. However, there is room for improvement in CORE EXT. Perhaps support can be added for simple static forward references.

Comments?

Re: RFD: Static forward references

<06376332-0029-4996-88d1-3e80897f2aecn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24260&group=comp.lang.forth#24260

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:4e88:0:b0:63c:f6d5:e9e1 with SMTP id dy8-20020ad44e88000000b0063cf6d5e9e1mr117666qvb.6.1691917580124;
Sun, 13 Aug 2023 02:06:20 -0700 (PDT)
X-Received: by 2002:a17:90b:e8b:b0:268:5c5d:25cf with SMTP id
fv11-20020a17090b0e8b00b002685c5d25cfmr1545717pjb.4.1691917579541; Sun, 13
Aug 2023 02:06:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 13 Aug 2023 02:06:18 -0700 (PDT)
In-Reply-To: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:ed:a70e:e801:10c8:6333:4cbb:7deb;
posting-account=mrP5kgoAAADXISqI3e5f4EXLUinHClBq
NNTP-Posting-Host: 2003:ed:a70e:e801:10c8:6333:4cbb:7deb
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <06376332-0029-4996-88d1-3e80897f2aecn@googlegroups.com>
Subject: Re: RFD: Static forward references
From: hheinrich.hohl@gmail.com (Heinrich Hohl)
Injection-Date: Sun, 13 Aug 2023 09:06:20 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Heinrich Hohl - Sun, 13 Aug 2023 09:06 UTC

On Sunday, August 13, 2023 at 5:43:22 AM UTC+2, Brad Eckert wrote:
> The usual way to handle forward references in Forth is to use DEFER and IS. The CORE EXT wordset includes some other goodies like ACTION-OF, DEFER!, and DEFER@.
>
> This usage provides a kind of OOPless late binding. Dynamic forward references can be changed by DEFER!. What if all you want is a static forward reference? The overhead is a waste of resources.
>
> I use LATER and RESOLVES:
>
> LATER foo \ compiles a jump instruction with a blank address
> : bar foo ... ;
> :noname ( foo ) ; RESOLVES foo \ fills in the address

I agree with your comments.

LMI PC/FORTH had F: and R: for this purpose. I found these commands very easy
to memorize and to use. F: defines a forward reference, and R: resolves it.
Example:

F: MENU

(other definitions)

R: MENU (here comes the actual code) ;

Re: RFD: Static forward references

<2023Aug13.103111@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24261&group=comp.lang.forth#24261

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: RFD: Static forward references
Date: Sun, 13 Aug 2023 08:31:11 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 66
Message-ID: <2023Aug13.103111@mips.complang.tuwien.ac.at>
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
Injection-Info: dont-email.me; posting-host="2cba55ac9f13cbb2f368f697c6716dfb";
logging-data="1877314"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/D93SyaFiHKkx6UroBlylt"
Cancel-Lock: sha1:iZHMtquvpZ74xdPvB3igUY1lQ8E=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sun, 13 Aug 2023 08:31 UTC

Brad Eckert <hwfwguy@gmail.com> writes:
>The usual way to handle forward references in Forth is to use DEFER and IS. The CORE EXT wordset includes some other goodies like ACTION-OF, DEFER!, and DEFER@.
>
>This usage provides a kind of OOPless late binding. Dynamic forward references can be changed by DEFER!. What if all you want is a static forward reference? The overhead is a waste of resources.
>
>I use LATER and RESOLVES:
>
>LATER foo \ compiles a jump instruction with a blank address
>: bar foo ... ;
>:noname ( foo ) ; RESOLVES foo \ fills in the address

Gforth (development) has FORWARD:

forward foo
: bar foo ;
: foo ." foo" ;

This does not exist because there was a pressing need for it, but
because we found a cute way to implement it. You can read about the
implementation in
<http://www.complang.tuwien.ac.at/forth/forward.txt>.

>So, there are some points I would like to make about DEFER:
>
>1. DEFER is used for two different things. The spirit of Forth is for words to do only one thing. It's overkill for the static case.

Another design principle in Forth is to avoid unnecessary complexity.
DEFER ... IS can be used to do what LATER ... RESOLVES do. Are there
really enough (and important enough) cases to justify the extra
complexity of LATER...RESOLVES or FORWARD?

>4. This is almost surely a matter of taste. I don't like to waste RAM and clock cycles.

Concerning RAM, the implementation of LATER...RESOLVES (and FORWARD)
has an up-front cost. How many DEFER definitions do you have to
replace with LATER definitions until you have amortized that cost? In
case of FORWARD, a FORWARD definition consumes two cells more than a
DEFER definition, and LIT-PERFORM (what Gforth compiles when compiling
a deferred word) is shorter than CALL (what Gforth compiles when
compiling a colon definition), so FORWARD does not save RAM in Gforth
under any circumstances.

Concerning cycles, yes, using FORWARD instead of DEFER reduces the
number of instructions executed for the word, and probably also the
number of cycles, but is it really significant? There are few cases
of mutual recursion, and even if one of them dominates the run-time,
how much of it is spent on the code for the deferred or forwarded
call?

On sophisticated CPUs, there is little performance difference between
a direct call and an indirect call that always calls the same target.

>There are plenty of those to burn these days. However, there is room for improvement in CORE EXT. Perhaps support can be added for simple static forward references.

If you want to propose an extension to the standard, the current way
to do this is to add a proposal at
<https://forth-standard.org/proposals>.

>
>Comments?

--
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 2023: https://euro.theforth.net/2023

Re: RFD: Static forward references

<nnd$26e851a9$2bb0f7db@89bb9ff1af2ad8a0>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24262&group=comp.lang.forth#24262

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
Subject: Re: RFD: Static forward references
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$26e851a9$2bb0f7db@89bb9ff1af2ad8a0>
Organization: KPN B.V.
Date: Sun, 13 Aug 2023 12:15:46 +0200
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!npeer.as286.net!npeer-ng0.as286.net!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe006.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 86
Injection-Date: Sun, 13 Aug 2023 12:15:46 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 4222
 by: none - Sun, 13 Aug 2023 10:15 UTC

In article <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>,
Brad Eckert <hwfwguy@gmail.com> wrote:
>The usual way to handle forward references in Forth is to use DEFER and
>IS. The CORE EXT wordset includes some other goodies like ACTION-OF,
>DEFER!, and DEFER@.
>
>This usage provides a kind of OOPless late binding. Dynamic forward
>references can be changed by DEFER!. What if all you want is a static
>forward reference? The overhead is a waste of resources.
>
>I use LATER and RESOLVES:
>
>LATER foo \ compiles a jump instruction with a blank address
>: bar foo ... ;
>:noname ( foo ) ; RESOLVES foo \ fills in the address
>
>So, there are some points I would like to make about DEFER:
>
>1. DEFER is used for two different things. The spirit of Forth is for
>words to do only one thing. It's overkill for the static case.
>
>2. IS can be "smartened up", or overloaded the way TO is, but the
>complexification is anti-Forth even if you can make it work.
>
>3. There could be better words to use than LATER and RESOLVES for static
>forward references. I have seen IST used, but we are not all German.
>
>4. This is almost surely a matter of taste. I don't like to waste RAM
>and clock cycles. There are plenty of those to burn these days. However,
>there is room for improvement in CORE EXT. Perhaps support can be added
>for simple static forward references.

I'm currently implementing MAL (make another lisp).
In those circumstances mutual recursive functions are common,
so it really depends. The proposal is to make a lisp in 10 steps.
You suddenly find that certain words must become mutual referring.

The solution is to have a dummy header ( and headers are needed
any way, however solution you may choose.)
An example using the infamous Fibonacci sequence.
:F FIB ; \ Forward
:R DUP IF DUP FIB SWAP 1- FIB + ELSE 0 THEN ; \ Resolve
The notation is unobtrusive, and why shouldn't it?

Crafting MAL, you are bound to discover that some words are
used in unexpected places. It sufficed to add
:F eval-item ;
and then fix the actual definition from
: eval-item ;
to
:R eval-item .... ;

The implementation is not complicated and share one screen with:
\ Alias of : , redefine an existing(!) word. Or crash.
: :2 ... ;
and
\ Alias of :, define a word that inlines it code.
: :I ... ;

>
>Comments?

My idea is the same, but I like my notation better.

In an indirect threaded Forth (like ciforth-family) there is no
penalty for this mechanism. In the end the two headers ("dictionary
entrie") are the same. After compilation is finished there is
as it were an extra header, that placed up front.
The patching that takes place in :R is to fill in a pointer to high
level core.
After compilation the code is static.

Vectors, that can be changed to adapt the behaviour of a program, so
writing to a file instead of writing to a terminal, is well served by
IS DEFER. I agree with you that that is a totally different
functionality.
Changing the behaviour of a compiled program *afterwards" is totally
different from recursion or mutual recursion.

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: RFD: Static forward references

<ubacja$1pinh$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24263&group=comp.lang.forth#24263

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxforth@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: RFD: Static forward references
Date: Sun, 13 Aug 2023 20:51:23 +1000
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <ubacja$1pinh$1@dont-email.me>
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
<2023Aug13.103111@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 13 Aug 2023 10:51:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4e83c4580745025ef8b2b034777136a0";
logging-data="1886961"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DDHqF/iqCbNo0ktHPRAiO"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:nCjaAe7cY9ZqqIJM9OUXDGn9ZP4=
Content-Language: en-GB
In-Reply-To: <2023Aug13.103111@mips.complang.tuwien.ac.at>
 by: dxforth - Sun, 13 Aug 2023 10:51 UTC

On 13/08/2023 6:31 pm, Anton Ertl wrote:
> Brad Eckert <hwfwguy@gmail.com> writes:
>> The usual way to handle forward references in Forth is to use DEFER and IS. The CORE EXT wordset includes some other goodies like ACTION-OF, DEFER!, and DEFER@.
>>
>> This usage provides a kind of OOPless late binding. Dynamic forward references can be changed by DEFER!. What if all you want is a static forward reference? The overhead is a waste of resources.
>>
>> I use LATER and RESOLVES:
>>
>> LATER foo \ compiles a jump instruction with a blank address
>> : bar foo ... ;
>> :noname ( foo ) ; RESOLVES foo \ fills in the address
>
> Gforth (development) has FORWARD:
>
> forward foo
> : bar foo ;
> : foo ." foo" ;
>
> This does not exist because there was a pressing need for it, but
> because we found a cute way to implement it. You can read about the
> implementation in
> <http://www.complang.tuwien.ac.at/forth/forward.txt>.
>
>> So, there are some points I would like to make about DEFER:
>>
>> 1. DEFER is used for two different things. The spirit of Forth is for words to do only one thing. It's overkill for the static case.
>
> Another design principle in Forth is to avoid unnecessary complexity.
> DEFER ... IS can be used to do what LATER ... RESOLVES do. Are there
> really enough (and important enough) cases to justify the extra
> complexity of LATER...RESOLVES or FORWARD?

About the same as DEFER@ DEFER! ACTION-OF BUFFER: etc

Re: RFD: Static forward references

<26ac6c2e-4c32-4cf6-8e01-8f548ca65444n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24264&group=comp.lang.forth#24264

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:904:b0:63d:44c5:3f37 with SMTP id dj4-20020a056214090400b0063d44c53f37mr89008qvb.12.1691938233489;
Sun, 13 Aug 2023 07:50:33 -0700 (PDT)
X-Received: by 2002:a17:90a:c388:b0:26b:4c47:eeae with SMTP id
h8-20020a17090ac38800b0026b4c47eeaemr475000pjt.5.1691938233005; Sun, 13 Aug
2023 07:50:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.niel.me!glou.org!news.glou.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Sun, 13 Aug 2023 07:50:32 -0700 (PDT)
In-Reply-To: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1c05:2f18:6d00:a5a9:4fe2:3de7:b2da;
posting-account=-JQ2RQoAAAB6B5tcBTSdvOqrD1HpT_Rk
NNTP-Posting-Host: 2001:1c05:2f18:6d00:a5a9:4fe2:3de7:b2da
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <26ac6c2e-4c32-4cf6-8e01-8f548ca65444n@googlegroups.com>
Subject: Re: RFD: Static forward references
From: mhx@iae.nl (Marcel Hendrix)
Injection-Date: Sun, 13 Aug 2023 14:50:33 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Marcel Hendrix - Sun, 13 Aug 2023 14:50 UTC

On Sunday, August 13, 2023 at 5:43:22 AM UTC+2, Brad Eckert wrote:
[..]
> 1. DEFER is used for two different things. The spirit of Forth is for words to do only one thing.
[..]
Maybe that statement is incomplete? See COUNT ( c@+ ), or 2>R ( DO ), or */MOD ( *, /, mod).
Good words do their best to be as low-level / general as possible. They can, and are, used wildly
out of context in some cases, where somebody renamed them to point out a useful re-purpose.
These two characteristics together make it natural to sequence a few of these primitives
together and give them a descriptive name that works better (for the user) in the context at
hand. The best names are ambiguous to make these sequences work in many contexts
(the same idea as in spoken languages).
It should be "COUNT," not "parse-string-descriptor_256."

-marcel

Re: RFD: Static forward references

<ubc43o$2528i$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24265&group=comp.lang.forth#24265

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxforth@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: RFD: Static forward references
Date: Mon, 14 Aug 2023 12:38:49 +1000
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ubc43o$2528i$1@dont-email.me>
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
<26ac6c2e-4c32-4cf6-8e01-8f548ca65444n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 14 Aug 2023 02:38:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b4f947b7d038e0cd1657f3c877574121";
logging-data="2263314"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yOZAPRgh7cTkiGZdgyhfG"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:IoXcY/zb/6gZnCv85G8VTIiZfpg=
In-Reply-To: <26ac6c2e-4c32-4cf6-8e01-8f548ca65444n@googlegroups.com>
Content-Language: en-GB
 by: dxforth - Mon, 14 Aug 2023 02:38 UTC

On 14/08/2023 12:50 am, Marcel Hendrix wrote:
> On Sunday, August 13, 2023 at 5:43:22 AM UTC+2, Brad Eckert wrote:
> [..]
>> 1. DEFER is used for two different things. The spirit of Forth is for words to do only one thing.
> [..]
> Maybe that statement is incomplete? See COUNT ( c@+ ), or 2>R ( DO ), or */MOD ( *, /, mod).
> Good words do their best to be as low-level / general as possible. They can, and are, used wildly
> out of context in some cases, where somebody renamed them to point out a useful re-purpose.
> These two characteristics together make it natural to sequence a few of these primitives
> together and give them a descriptive name that works better (for the user) in the context at
> hand. The best names are ambiguous to make these sequences work in many contexts
> (the same idea as in spoken languages).
> It should be "COUNT," not "parse-string-descriptor_256."

Speaking of which ANS hoped the "-FILE" words would one day be shortened. They're
certainly an eye-sore. Likely too late now.

Re: RFD: Static forward references

<nnd$4fb80ca0$23a8005f@ee325e5e368b3618>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24266&group=comp.lang.forth#24266

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: RFD: Static forward references
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com> <06376332-0029-4996-88d1-3e80897f2aecn@googlegroups.com>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$4fb80ca0$23a8005f@ee325e5e368b3618>
Organization: KPN B.V.
Date: Mon, 14 Aug 2023 09:53:40 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 38
Injection-Date: Mon, 14 Aug 2023 09:53:40 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2046
 by: none - Mon, 14 Aug 2023 07:53 UTC

In article <06376332-0029-4996-88d1-3e80897f2aecn@googlegroups.com>,
Heinrich Hohl <hheinrich.hohl@gmail.com> wrote:
>On Sunday, August 13, 2023 at 5:43:22 AM UTC+2, Brad Eckert wrote:
>> The usual way to handle forward references in Forth is to use DEFER
>and IS. The CORE EXT wordset includes some other goodies like ACTION-OF,
>DEFER!, and DEFER@.
>>
>> This usage provides a kind of OOPless late binding. Dynamic forward
>references can be changed by DEFER!. What if all you want is a static
>forward reference? The overhead is a waste of resources.
>>
>> I use LATER and RESOLVES:
>>
>> LATER foo \ compiles a jump instruction with a blank address
>> : bar foo ... ;
>> :noname ( foo ) ; RESOLVES foo \ fills in the address
>
>I agree with your comments.
>
>LMI PC/FORTH had F: and R: for this purpose. I found these commands very easy
>to memorize and to use. F: defines a forward reference, and R: resolves it.
>Example:
>
>F: MENU
>
>(other definitions)
>
>R: MENU (here comes the actual code) ;

I have :F and :R. Damn!

Groetjes Albert
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -

Re: RFD: Static forward references

<dcba82dc-6dd3-42a9-bb7e-6c6144a7db2an@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24267&group=comp.lang.forth#24267

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:4b28:0:b0:63d:b79:43ab with SMTP id s8-20020ad44b28000000b0063d0b7943abmr117110qvw.4.1692000956025;
Mon, 14 Aug 2023 01:15:56 -0700 (PDT)
X-Received: by 2002:a17:902:ec85:b0:1bd:dcdf:6179 with SMTP id
x5-20020a170902ec8500b001bddcdf6179mr1378610plg.2.1692000955490; Mon, 14 Aug
2023 01:15:55 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!3.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Mon, 14 Aug 2023 01:15:54 -0700 (PDT)
In-Reply-To: <2023Aug13.103111@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:ed:a70e:e801:ed08:5cb3:be78:57ff;
posting-account=mrP5kgoAAADXISqI3e5f4EXLUinHClBq
NNTP-Posting-Host: 2003:ed:a70e:e801:ed08:5cb3:be78:57ff
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com> <2023Aug13.103111@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dcba82dc-6dd3-42a9-bb7e-6c6144a7db2an@googlegroups.com>
Subject: Re: RFD: Static forward references
From: hheinrich.hohl@gmail.com (Heinrich Hohl)
Injection-Date: Mon, 14 Aug 2023 08:15:56 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 18
 by: Heinrich Hohl - Mon, 14 Aug 2023 08:15 UTC

On Sunday, August 13, 2023 at 11:34:49 AM UTC+2, Anton Ertl wrote:
> Another design principle in Forth is to avoid unnecessary complexity.
> DEFER ... IS can be used to do what LATER ... RESOLVES do. Are there
> really enough (and important enough) cases to justify the extra
> complexity of LATER...RESOLVES or FORWARD?

In my opinion the main benefit of forwarding/resolving a colon definition
(instead of DEFER and IS) is clarity of code. In the first case we have
static behavior, in the second case a self-modifying program.

A similar case where we introduced two different words for almost the same
task are CONSTANT and VALUE

CONSTANT is not really needed if we have VALUE at hand because we could store any
constant number using VALUE just as well. But if we use CONSTANT in this case
we point out clearly that the stored number is not supposed to be changed anywhere in the program.

Re: RFD: Static forward references

<20230814105213.6c705521@t530>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24269&group=comp.lang.forth#24269

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jan4comp.lang.forth@murray-microft.co.uk (jan Coombs)
Newsgroups: comp.lang.forth
Subject: Re: RFD: Static forward references
Date: Mon, 14 Aug 2023 10:52:13 +0100
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <20230814105213.6c705521@t530>
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
<2023Aug13.103111@mips.complang.tuwien.ac.at>
<dcba82dc-6dd3-42a9-bb7e-6c6144a7db2an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="504719960bf310b1a2eaadbb14d7187e";
logging-data="2356344"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19G6WfUKjxsW9vRBikECjlyGFfXca72+QM="
Cancel-Lock: sha1:WblI4tcHnCYAK4y2AzPGROFP+xY=
X-Newsreader: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
 by: jan Coombs - Mon, 14 Aug 2023 09:52 UTC

On Mon, 14 Aug 2023 01:15:54 -0700 (PDT)
Heinrich Hohl <hheinrich.hohl@gmail.com> wrote:

> In my opinion the main benefit of forwarding/resolving a colon definition
> (instead of DEFER and IS) is clarity of code. In the first case we have
> static behavior, in the second case a self-modifying program.
>
> A similar case where we introduced two different words for almost the same
> task are CONSTANT and VALUE

Agreed, I also prefer words to be intention-explicit, even when code is same.

Jan Coombs
--

Re: RFD: Static forward references

<ubd0t2$2909a$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24270&group=comp.lang.forth#24270

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxforth@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: RFD: Static forward references
Date: Mon, 14 Aug 2023 20:50:09 +1000
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <ubd0t2$2909a$1@dont-email.me>
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
<2023Aug13.103111@mips.complang.tuwien.ac.at>
<dcba82dc-6dd3-42a9-bb7e-6c6144a7db2an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 14 Aug 2023 10:50:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b4f947b7d038e0cd1657f3c877574121";
logging-data="2392362"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19URkui6jqpLNg9c4x5iIm6"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:TL8Px2UASjnV0QMKW3iJdPHoIrc=
In-Reply-To: <dcba82dc-6dd3-42a9-bb7e-6c6144a7db2an@googlegroups.com>
Content-Language: en-GB
 by: dxforth - Mon, 14 Aug 2023 10:50 UTC

On 14/08/2023 6:15 pm, Heinrich Hohl wrote:
> On Sunday, August 13, 2023 at 11:34:49 AM UTC+2, Anton Ertl wrote:
>> Another design principle in Forth is to avoid unnecessary complexity.
>> DEFER ... IS can be used to do what LATER ... RESOLVES do. Are there
>> really enough (and important enough) cases to justify the extra
>> complexity of LATER...RESOLVES or FORWARD?
>
> In my opinion the main benefit of forwarding/resolving a colon definition
> (instead of DEFER and IS) is clarity of code. In the first case we have
> static behavior, in the second case a self-modifying program.
>
> A similar case where we introduced two different words for almost the same
> task are CONSTANT and VALUE
>
> CONSTANT is not really needed if we have VALUE at hand because we could store any
> constant number using VALUE just as well. But if we use CONSTANT in this case
> we point out clearly that the stored number is not supposed to be changed anywhere in the program.

Changing a CONSTANT amounts to a hot patch. VALUE and DEFER are
alike in that the thing that changes is implicitly VARIABLE.
IIRC the only things in Forth that perform a hot patch are DOES>
and IMMEDIATE and are disliked for that reason.

Re: RFD: Static forward references

<2023Aug14.160310@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24272&group=comp.lang.forth#24272

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: RFD: Static forward references
Date: Mon, 14 Aug 2023 14:03:10 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 32
Message-ID: <2023Aug14.160310@mips.complang.tuwien.ac.at>
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com> <2023Aug13.103111@mips.complang.tuwien.ac.at> <dcba82dc-6dd3-42a9-bb7e-6c6144a7db2an@googlegroups.com>
Injection-Info: dont-email.me; posting-host="81f33ac512e6dd79ae1ca3f4b44ae9a0";
logging-data="2487607"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kk8A7TKRNxLYd86eZ2+np"
Cancel-Lock: sha1:+347f+AjhT0ududIv54frGnQYJY=
X-newsreader: xrn 10.11
 by: Anton Ertl - Mon, 14 Aug 2023 14:03 UTC

Heinrich Hohl <hheinrich.hohl@gmail.com> writes:
>On Sunday, August 13, 2023 at 11:34:49=E2=80=AFAM UTC+2, Anton Ertl wrote:
>> Are there=20
>> really enough (and important enough) cases to justify the extra=20
>> complexity of LATER...RESOLVES or FORWARD?
....
>A similar case where we introduced two different words for almost the same
>task are CONSTANT and VALUE

Yes, we could have used VALUE instead of CONSTANT, and if VALUE had
been introduced first, maybe we would never have introduced CONSTANT.

However, looking at the occurences in the sources of Gforth's image
(without kernel; building the kernel uses the cross-compiler, with its
own instances of defining words), there is one big difference between
these two situations:

occurences read-only read/write
CONSTANT/VALUE 162 33
FORWARD/DEFER 0 40

Admittedly FORWARD is recent, so maybe some cases are covered by DEFER
that are actually hidden FORWARDs (but no such case comes to my mind).
Also, there are forward references in the kernel which are resolved
automatically by the cross-compiler.

- 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 2023: https://euro.theforth.net/2023

Re: RFD: Static forward references

<af8181c2-9f9d-43b0-b819-5297b291e029n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24283&group=comp.lang.forth#24283

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ac8:4e51:0:b0:40f:f2e0:af7e with SMTP id e17-20020ac84e51000000b0040ff2e0af7emr3832qtw.10.1692140780096;
Tue, 15 Aug 2023 16:06:20 -0700 (PDT)
X-Received: by 2002:a17:902:ce8e:b0:1bb:91c9:d334 with SMTP id
f14-20020a170902ce8e00b001bb91c9d334mr98913plg.0.1692140779565; Tue, 15 Aug
2023 16:06:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!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: Tue, 15 Aug 2023 16:06:18 -0700 (PDT)
In-Reply-To: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=77.174.47.232; posting-account=Ebqe4AoAAABfjCRL4ZqOHWv4jv5ZU4Cs
NNTP-Posting-Host: 77.174.47.232
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <af8181c2-9f9d-43b0-b819-5297b291e029n@googlegroups.com>
Subject: Re: RFD: Static forward references
From: the.beez.speaks@gmail.com (Hans Bezemer)
Injection-Date: Tue, 15 Aug 2023 23:06:20 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3244
 by: Hans Bezemer - Tue, 15 Aug 2023 23:06 UTC

On Sunday, August 13, 2023 at 5:43:22 AM UTC+2, Brad Eckert wrote:
> The usual way to handle forward references in Forth is to use DEFER and IS. The CORE EXT wordset includes some other goodies like ACTION-OF, DEFER!, and DEFER@.
>
> This usage provides a kind of OOPless late binding. Dynamic forward references can be changed by DEFER!. What if all you want is a static forward reference? The overhead is a waste of resources.
>
> I use LATER and RESOLVES:
>
> LATER foo \ compiles a jump instruction with a blank address
> : bar foo ... ;
> :noname ( foo ) ; RESOLVES foo \ fills in the address
>
> So, there are some points I would like to make about DEFER:
>
> 1. DEFER is used for two different things. The spirit of Forth is for words to do only one thing. It's overkill for the static case.
>
> 2. IS can be "smartened up", or overloaded the way TO is, but the complexification is anti-Forth even if you can make it work.
>
> 3. There could be better words to use than LATER and RESOLVES for static forward references. I have seen IST used, but we are not all German.
>
> 4. This is almost surely a matter of taste. I don't like to waste RAM and clock cycles. There are plenty of those to burn these days. However, there is room for improvement in CORE EXT. Perhaps support can be added for simple static forward references.
>
> Comments?
4tH has got PROTO: <name> for defining it and :PROTO <name> for resolving it. The former creates two jumps.
The first one jumps over the second, blank one - and is the target for the calls to it.

The later patches the blank jump address to match its own. It also makes sure that subsequent calls
go to the true address, rather than the trampoline.

Performance wise the difference with DEFER is negligable. It tend to use DEFER when the program
must or can change its target word. A static forward is done with :PROTO. I try to cut down on my
data consumption ;-)

Hans Bezemer

Re: RFD: Static forward references

<ubhgnu$35sgf$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=24284&group=comp.lang.forth#24284

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxforth@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: RFD: Static forward references
Date: Wed, 16 Aug 2023 13:45:02 +1000
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ubhgnu$35sgf$1@dont-email.me>
References: <aa585f45-b229-4a0a-a304-fd8233dbbeb8n@googlegroups.com>
<af8181c2-9f9d-43b0-b819-5297b291e029n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 16 Aug 2023 03:45:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0f97586e4f6fffea406d906c75f7e747";
logging-data="3338767"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jv4qPLnG/52MiBcfL7HdY"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:Msl9HxawglBWBhwtTiaK+dM61RY=
In-Reply-To: <af8181c2-9f9d-43b0-b819-5297b291e029n@googlegroups.com>
Content-Language: en-GB
 by: dxforth - Wed, 16 Aug 2023 03:45 UTC

On 16/08/2023 9:06 am, Hans Bezemer wrote:
> ...
> Performance wise the difference with DEFER is negligable. It tend to use DEFER when the program
> must or can change its target word. A static forward is done with :PROTO. I try to cut down on my
> data consumption ;-)

This raises the question of what embedded systems use - particularly those
claiming allegiance to ANS. I notice ANS target compilers are quite smart
when it comes to CREATE DOES>. Is there anything that prevents them being
smart about DEFER IS ?

If embedded concepts are to be included in Standard Forth, it deserves its
own section - if only to keep sanity. It's where I'd put BUFFER: assuming
it was ever needed.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor