Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Philosophy: A route of many roads leading from nowhere to nothing. -- Ambrose Bierce


devel / comp.lang.forth / Re: FOR-EACH ... DO[ ... ]NEXT

SubjectAuthor
* FOR-EACH ... DO[ ... ]NEXTGerry Jackson
+* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
|+* Re: FOR-EACH ... DO[ ... ]NEXTnone
||`- Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
|`* Re: FOR-EACH ... DO[ ... ]NEXTminforth
| `- Re: FOR-EACH ... DO[ ... ]NEXTnone
+* Re: FOR-EACH ... DO[ ... ]NEXTAnton Ertl
|+- Re: FOR-EACH ... DO[ ... ]NEXTAnton Ertl
|+* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||+- Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||`* Re: FOR-EACH ... DO[ ... ]NEXTAnton Ertl
|| +- Re: FOR-EACH ... DO[ ... ]NEXTnone
|| `* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||  `* Re: FOR-EACH ... DO[ ... ]NEXTHelmut Eller
||   `* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||    `* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||     +* Re: FOR-EACH ... DO[ ... ]NEXTRuvim
||     |`- Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||     +* Re: FOR-EACH ... DO[ ... ]NEXTRuvim
||     |+* Re: FOR-EACH ... DO[ ... ]NEXTdxf
||     ||`* Re: FOR-EACH ... DO[ ... ]NEXTAnton Ertl
||     || `- Re: FOR-EACH ... DO[ ... ]NEXTdxf
||     |`- Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||     `* Re: FOR-EACH ... DO[ ... ]NEXTAnton Ertl
||      `* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||       +* Re: FOR-EACH ... DO[ ... ]NEXTminforth
||       |`* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||       | +* Re: FOR-EACH ... DO[ ... ]NEXTminforth
||       | |+- Re: FOR-EACH ... DO[ ... ]NEXTdxf
||       | |+* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||       | ||+* Re: FOR-EACH ... DO[ ... ]NEXTRuvim
||       | |||`* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||       | ||| `* Re: FOR-EACH ... DO[ ... ]NEXTRuvim
||       | |||  +- Re: FOR-EACH ... DO[ ... ]NEXTnone
||       | |||  `* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||       | |||   `* Re: FOR-EACH ... DO[ ... ]NEXTHans Bezemer
||       | |||    `- Re: FOR-EACH ... DO[ ... ]NEXTnone
||       | ||`- Re: FOR-EACH ... DO[ ... ]NEXTminforth
||       | |+- Re: FOR-EACH ... DO[ ... ]NEXTnone
||       | |`- Re: FOR-EACH ... DO[ ... ]NEXTAnton Ertl
||       | +* Documenting system-specific behavior (was: FOR-EACH ... DO[ ...Ruvim
||       | |`* Re: Documenting system-specific behaviorRuvim
||       | | `* Re: Documenting system-specific behaviordxf
||       | |  `* Re: Documenting system-specific behaviorAnton Ertl
||       | |   `* Re: Documenting system-specific behaviordxf
||       | |    `* Re: Documenting system-specific behaviorAnton Ertl
||       | |     `- Re: Documenting system-specific behaviordxf
||       | `- Re: FOR-EACH ... DO[ ... ]NEXTAnton Ertl
||       `* Re: FOR-EACH ... DO[ ... ]NEXTAnton Ertl
||        `* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
||         `* Re: FOR-EACH ... DO[ ... ]NEXTAnton Ertl
||          `- Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
|`* Re: FOR-EACH ... DO[ ... ]NEXTRuvim
| `* Re: FOR-EACH ... DO[ ... ]NEXTdxf
|  `* Re: FOR-EACH ... DO[ ... ]NEXTRuvim
|   `* Re: FOR-EACH ... DO[ ... ]NEXTdxf
|    `- Re: FOR-EACH ... DO[ ... ]NEXTJan Coombs
+* Re: FOR-EACH ... DO[ ... ]NEXTHans Bezemer
|`* Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson
| +- Re: FOR-EACH ... DO[ ... ]NEXTDoug Hoffman
| +- Re: FOR-EACH ... DO[ ... ]NEXTminforth
| `- Re: FOR-EACH ... DO[ ... ]NEXTHans Bezemer
`* Re: FOR-EACH ... DO[ ... ]NEXTHelmut Eller
 `- Re: FOR-EACH ... DO[ ... ]NEXTGerry Jackson

Pages:123
Re: FOR-EACH ... DO[ ... ]NEXT

<2023Dec8.154436@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.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: FOR-EACH ... DO[ ... ]NEXT
Date: Fri, 08 Dec 2023 14:44:36 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 53
Message-ID: <2023Dec8.154436@mips.complang.tuwien.ac.at>
References: <uilq87$2tvlh$1@dont-email.me> <2023Nov14.183012@mips.complang.tuwien.ac.at> <uj2rs1$1qftu$1@dont-email.me> <2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me> <m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me> <ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at> <uks326$176qs$1@dont-email.me> <2023Dec7.181152@mips.complang.tuwien.ac.at> <uktfd3$1dfna$2@dont-email.me>
Injection-Info: dont-email.me; posting-host="bc1a1ba2cd1bf02df6681add8f69a0c2";
logging-data="1882810"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX198/hy/oN35g2KrdGKLaXQ2"
Cancel-Lock: sha1:c4ddhstdAjQbDQfzjNeXYoyROv0=
X-newsreader: xrn 10.11
 by: Anton Ertl - Fri, 8 Dec 2023 14:44 UTC

Gerry Jackson <do-not-use@swldwa.uk> writes:
>I'm curious about why you think auto-scoping locals is worth the trouble
> when the philosophy of Forth in general is 'let the programmer
>beware'.

I don't care that much for claims about "the philosophy of Forth". I
have seen too much nonsense advocated with this claimed philosophy;
things along the lines of: The philosophy demands that we do it this
way, because it makes this particular word shorter by a few bytes; who
cares if this word is used dozens of times, and every use becomes
harder, more error-prone, or even bigger or slower. I care!

Anyway, you have given an example of why it is useful to define locals
inside control structures in <ukteh9$1dfna$1@dont-email.me>, and I use
that a lot. Now, if we want that, but are also required by the
standard to implement general control flow as discussed in A.3.2.3.2,
I need to define the lifetime and visibility of the locals, and
ideally they should live at least as long as they are visible. I
found a solution to this problem [ertl94l], so I implemented it.

Now, 29 years later, there is the first complaint about the main
weakness of the solution, but fortunately it is possible to fix that,
too.

@InProceedings{ertl94l,
author = "M. Anton Ertl",
title = "Automatic Scoping of Local Variables",
booktitle = "EuroForth~'94 Conference Proceedings",
year = "1994",
address = "Winchester, UK",
pages = "31--37",
url = "http://www.complang.tuwien.ac.at/papers/ertl94l.ps.gz",
abstract = "In the process of lifting the restrictions on using
locals in Forth, an interesting problem poses
itself: What does it mean if a local is defined in a
control structure? Where is the local visible? Since
the user can create every possible control structure
in ANS Forth, the answer is not as simple as it may
seem. Ideally, the local is visible at a place if
the control flow {\em must} pass through the
definition of the local to reach this place. This
paper discusses locals in general, the visibility
problem, its solution, the consequences and the
implementation as well as related programming style
questions."
}

- 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: FOR-EACH ... DO[ ... ]NEXT

<2023Dec8.160247@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.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: FOR-EACH ... DO[ ... ]NEXT
Date: Fri, 08 Dec 2023 15:02:47 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 33
Message-ID: <2023Dec8.160247@mips.complang.tuwien.ac.at>
References: <uilq87$2tvlh$1@dont-email.me> <2023Nov14.183012@mips.complang.tuwien.ac.at> <uj2rs1$1qftu$1@dont-email.me> <2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me> <m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me> <ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at> <uks326$176qs$1@dont-email.me> <d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com> <ukteh9$1dfna$1@dont-email.me> <eca9d334109ee6b72ce83a7b0b754f74@news.novabbs.com>
Injection-Info: dont-email.me; posting-host="bc1a1ba2cd1bf02df6681add8f69a0c2";
logging-data="1887095"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18J2+g1GiVmfNzQUy+e1kmF"
Cancel-Lock: sha1:Ct6RQSOw4Y3ilUu0L0kghtSfZ2Y=
X-newsreader: xrn 10.11
 by: Anton Ertl - Fri, 8 Dec 2023 15:02 UTC

minforth@gmx.net (minforth) writes:
>The standard distinguishes between <arg> and <val> locals. The latter
>are not initialised; in the locals declaration they appear after a
>vertical bar character.
>
>IIRC in gforth you can use {: ... :} multiple times within a word
>definition. It would therefore be perfectly possible to use {: | b :}
>within a control structure without logical conflicts.

Yes, it's possible. What's your point?

The "| ..." part of the {:...:} syntax is unnecessary. Instead of

{: ... | x y z :}

one could write

0 0 0 {: ... x y z :}

But I don't need either in my code, because, by being able to define
locals anywhere, I define them when the initial value is known, so no
need to define it earlier uninitialized and then set the value later.

Looking in the Gforth sources, the use of '|' in a locals definition
is usually for cases where a local buffer is defined with the 'name['
syntax.

- 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: FOR-EACH ... DO[ ... ]NEXT

<ukvvg6$1sd77$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!news.chmurka.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: do-not-use@swldwa.uk (Gerry Jackson)
Newsgroups: comp.lang.forth
Subject: Re: FOR-EACH ... DO[ ... ]NEXT
Date: Fri, 8 Dec 2023 20:49:11 +0000
Organization: A noiseless patient Spider
Lines: 82
Message-ID: <ukvvg6$1sd77$1@dont-email.me>
References: <uilq87$2tvlh$1@dont-email.me>
<2023Nov14.183012@mips.complang.tuwien.ac.at> <uj2rs1$1qftu$1@dont-email.me>
<2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me>
<m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me>
<ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at>
<uks326$176qs$1@dont-email.me>
<d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com>
<ukteh9$1dfna$1@dont-email.me>
<eca9d334109ee6b72ce83a7b0b754f74@news.novabbs.com>
<ukuj3k$1lkdh$1@dont-email.me> <ukus7r$1n9tc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 8 Dec 2023 20:49:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fd8f11b6de5950dab2f745d1928aaf5b";
logging-data="1979623"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+DHsnXqgX18FgzrsS05XuEwsr2LjPYwUc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:M9vHT8ymbWjj55b8pSyjeeo/CP8=
In-Reply-To: <ukus7r$1n9tc$1@dont-email.me>
Content-Language: en-GB
 by: Gerry Jackson - Fri, 8 Dec 2023 20:49 UTC

On 08/12/2023 10:47, Ruvim wrote:
> On 2023-12-08 12:11, Gerry Jackson wrote:
> [...]
>>
>> Two things about FOR-EACH I don't think I've yet mentioned.
>>
>> The pipeline operator is optional. Without it the whole thing reverts
>> to a BEGIN ... WHILE ... REPEAT loop with a small amount of redundant
>> code. So why use FOR-EACH, IMHO the FOR-EACH is arguably more readable.
>>
>> The pipeline operator can make the FOR-EACH statement equivalent to
>> multi-WHILE loops without the drawbacks of ELSE parts being separated
>> in the source code.
>
> OTOH, FOR-EACH part is also optional. A pipeline operator can be used
> instead:
>
>   FOR-EACH TRUE DO[ next-item |> check-item |> process-item ]NEXT
>
> It's not obvious to me that placing "next-item" into a separate section
> rather than into the chain (like in this example) makes readability better.

You're probably right, my intention was to highlight that the first item
had to be something that iterated through a collection. But without
thinking it through I guess that's a fairly minor change to make. It
would also eliminate the need for DO[

>
> Also, I would use different operators to break and to continue the loop,
> instead of different signs of the input value.
>

Do you mean three operators that could be placed between the pipeline
operationsi.e. retaining the
iterator pipe-operator operation pipe-operator ... sequence

where we have three different pipe operators that, for the sake of
argument, might be:

|> for Proceed currently handled by a value 0
<|x for exit pipeline back, currently <0, like C continue
|x> for exit pipeline forward, currently >0, like C break

But without thinking about it deeply I don't see how that would work as
the decision about which option to take is at run-time not compile-time.

Whether this is managed by conditional jumps or possibly quotations ISTM
that there is always a choice of 1 from 3 has to be made at runtime.

Or did you have another idea in mind?

>
>> In addition using IF statements before the |> operator the programmer
>> has the option of continuing the loop, breaking the pipeline and
>> continuing or breaking the loop. This is also true of Gforth's CASE
>> extensions but I would argue readability again.
>>
>
> A small clarification: the operator "|>" cannot be placed inside an "IF"
> statement. Only its input value can be calculated (using "IF", or any
> other words).
>

Yes that is correct in general. If the IF was in the pipeline code it
could possibly be accomodated using a CS-ROLL or CS-PICK but of course
it could be in a separate colon definition when it would be impossible.
I was envisioning the arms of the IF ... ELSE ... THEN generating the
appropriate one of the three possibilites <0 0 >0 to be handled by the
following |>.

>
> --
> Ruvim
>

Sorry but I won't be able to work on this again until Sunday. Thanks for
your comments, it's certainly making me think about it more so we should
hopefully end up with a better solution.

--
Gerry

Re: FOR-EACH ... DO[ ... ]NEXT

<ul02tv$1sd77$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: do-not-use@swldwa.uk (Gerry Jackson)
Newsgroups: comp.lang.forth
Subject: Re: FOR-EACH ... DO[ ... ]NEXT
Date: Fri, 8 Dec 2023 21:47:44 +0000
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <ul02tv$1sd77$2@dont-email.me>
References: <uilq87$2tvlh$1@dont-email.me>
<2023Nov14.183012@mips.complang.tuwien.ac.at> <uj2rs1$1qftu$1@dont-email.me>
<2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me>
<m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me>
<ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at>
<uks326$176qs$1@dont-email.me> <2023Dec7.181152@mips.complang.tuwien.ac.at>
<uktfd3$1dfna$2@dont-email.me> <2023Dec8.154436@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 8 Dec 2023 21:47:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fd8f11b6de5950dab2f745d1928aaf5b";
logging-data="1979623"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18V86c92yea9TalxsBVuyTpO+s10uheXeY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:TOHCuoxRZFnE3osHl2vE1dSwd7A=
In-Reply-To: <2023Dec8.154436@mips.complang.tuwien.ac.at>
Content-Language: en-GB
 by: Gerry Jackson - Fri, 8 Dec 2023 21:47 UTC

On 08/12/2023 14:44, Anton Ertl wrote:
> Gerry Jackson <do-not-use@swldwa.uk> writes:
>> I'm curious about why you think auto-scoping locals is worth the trouble
>> when the philosophy of Forth in general is 'let the programmer
>> beware'.
>
> I don't care that much for claims about "the philosophy of Forth". I
> have seen too much nonsense advocated with this claimed philosophy;
> things along the lines of: The philosophy demands that we do it this
> way, because it makes this particular word shorter by a few bytes; who
> cares if this word is used dozens of times, and every use becomes
> harder, more error-prone, or even bigger or slower. I care!
>
> Anyway, you have given an example of why it is useful to define locals
> inside control structures in <ukteh9$1dfna$1@dont-email.me>, and I use
> that a lot. Now, if we want that, but are also required by the
> standard to implement general control flow as discussed in A.3.2.3.2,
> I need to define the lifetime and visibility of the locals, and
> ideally they should live at least as long as they are visible. I
> found a solution to this problem [ertl94l], so I implemented it.
>
> Now, 29 years later, there is the first complaint about the main
> weakness of the solution, but fortunately it is possible to fix that,
> too.

I seem to remember years ago that I caused you to improve code generated
by Gray many years after Gray had been developed. I'm getting to be a
nuisance :)

>
> @InProceedings{ertl94l,
> author = "M. Anton Ertl",
> title = "Automatic Scoping of Local Variables",
> booktitle = "EuroForth~'94 Conference Proceedings",
> year = "1994",
> address = "Winchester, UK",
> pages = "31--37",
> url = "http://www.complang.tuwien.ac.at/papers/ertl94l.ps.gz",
> abstract = "In the process of lifting the restrictions on using
> locals in Forth, an interesting problem poses
> itself: What does it mean if a local is defined in a
> control structure? Where is the local visible? Since
> the user can create every possible control structure
> in ANS Forth, the answer is not as simple as it may
> seem. Ideally, the local is visible at a place if
> the control flow {\em must} pass through the
> definition of the local to reach this place. This
> paper discusses locals in general, the visibility
> problem, its solution, the consequences and the
> implementation as well as related programming style
> questions."
> }
>

I see, a research topic

--
Gerry

Re: Documenting system-specific behavior

<ul0q90$23j65$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxforth@gmail.com (dxf)
Newsgroups: comp.lang.forth
Subject: Re: Documenting system-specific behavior
Date: Sat, 9 Dec 2023 15:26:08 +1100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <ul0q90$23j65$1@dont-email.me>
References: <uilq87$2tvlh$1@dont-email.me>
<2023Nov14.183012@mips.complang.tuwien.ac.at> <uj2rs1$1qftu$1@dont-email.me>
<2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me>
<m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me>
<ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at>
<uks326$176qs$1@dont-email.me>
<d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com>
<ukteh9$1dfna$1@dont-email.me> <ukuquj$1muv1$1@dont-email.me>
<ukuv6l$1nmr2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 9 Dec 2023 04:26:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="883f75cd70374a3bca36277a430e074b";
logging-data="2215109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ve86RM2YdVMrDHPr/d3HN"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:QXrpjgj28afXzJ2MHKfcEE1iw8U=
In-Reply-To: <ukuv6l$1nmr2$1@dont-email.me>
Content-Language: en-GB
 by: dxf - Sat, 9 Dec 2023 04:26 UTC

On 8/12/2023 10:37 pm, Ruvim wrote:
> On 2023-12-08 14:25, Ruvim wrote:
>> On 2023-12-08 01:47, Gerry Jackson wrote:
>>>
>>>
>>> As Gforth can declare locals within control structures it is clearly non-standard as the restriction you quote uses 'shall not' instead of making it an ambiguous condition.
>>
>> In both cases (i.e., regardless of the form), it is non-standard for *programs* and only for programs. A system is allowed to provide this capability, and non-standard programs can use this capability.
>
> Well, probably I was not quite correct here.
>
> The section "3 Usage requirements" <https://forth-standard.org/standard/usage#usage> says:
>   "A program that requires a system to provide words or techniques not defined in this standard has an environmental dependency."
>
> So, if a program requires a specific behavior in the case of some ambiguous condition, it can be considered as just an environmental dependency. Especially, if this requirement is mentioned in the program's documentation.

A program that relies on an 'ambiguous condition' can hardly be portable.
If ANS wants to claim documenting it will make it 'standard' that's their
business and yours if you choose to buy into it.

Re: Documenting system-specific behavior

<2023Dec9.081824@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.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: Documenting system-specific behavior
Date: Sat, 09 Dec 2023 07:18:24 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 45
Message-ID: <2023Dec9.081824@mips.complang.tuwien.ac.at>
References: <uilq87$2tvlh$1@dont-email.me> <uj2rs1$1qftu$1@dont-email.me> <2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me> <m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me> <ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at> <uks326$176qs$1@dont-email.me> <d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com> <ukteh9$1dfna$1@dont-email.me> <ukuquj$1muv1$1@dont-email.me> <ukuv6l$1nmr2$1@dont-email.me> <ul0q90$23j65$1@dont-email.me>
Injection-Info: dont-email.me; posting-host="81982e2b7fe220322b820553c5d7fd2f";
logging-data="2257988"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hnf2d2+pjKuzUHH4lxMwz"
Cancel-Lock: sha1:EjK1I5QuLsfwv2fZOodUnyQwCPs=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 9 Dec 2023 07:18 UTC

dxf <dxforth@gmail.com> writes:
>A program that relies on an 'ambiguous condition' can hardly be portable.

That depends on the ambiguous condition. In particular, looking at
<https://forth-standard.org/standard/doc#subsection.4.1.2>, I see

|producing a result out of range, e.g., multiplication (using *)
|results in a value too big to be represented by a single-cell integer
|(6.1.0090 *, 6.1.0100 */, 6.1.0110 */MOD, 6.1.0570 >NUMBER, 6.1.1561
|FM/MOD, 6.1.2214 SM/REM, 6.1.2370 UM/MOD, 8.6.1.1820 M*/);

Certainly for * every system with a given cell size produces the same
result. This has led to the result of * overflow being standardized
in the next release <http://www.forth200x.org/twos-complement.html>.
It's interesting that this ambiguous condition does not mention +, -,
or it's variants.

Bottom line: In some cases there is common practice even if it has not
been standardized.

I don't think that the documentation in 4.1.2 is useful to find such
common practice, though.

>If ANS wants to claim documenting it will make it 'standard' that's their
>business and yours if you choose to buy into it.

I don't know who this ANS is and why he/she would "want to claim" such
a thing, and why anybody should care about such a supposed urge, if
he/she does not actually make such a claim.

In any case, Forth-94 and Forth-2012 require standard systems to
document some ambiguous conditions. As you point out, that certainly
does not help in writing portable programs.

If the behaviour is considered a feature by the Forth system
implementor, the behaviour will certainly be documented without such a
requirement. If it is not a feature, what use should a programmer
have from the documentation?

- 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: Documenting system-specific behavior

<ul19rn$254ed$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxforth@gmail.com (dxf)
Newsgroups: comp.lang.forth
Subject: Re: Documenting system-specific behavior
Date: Sat, 9 Dec 2023 19:52:07 +1100
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <ul19rn$254ed$1@dont-email.me>
References: <uilq87$2tvlh$1@dont-email.me> <uj2rs1$1qftu$1@dont-email.me>
<2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me>
<m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me>
<ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at>
<uks326$176qs$1@dont-email.me>
<d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com>
<ukteh9$1dfna$1@dont-email.me> <ukuquj$1muv1$1@dont-email.me>
<ukuv6l$1nmr2$1@dont-email.me> <ul0q90$23j65$1@dont-email.me>
<2023Dec9.081824@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 9 Dec 2023 08:52:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="883f75cd70374a3bca36277a430e074b";
logging-data="2265549"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182qUfVAZZgdekOKEsRhBr8"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:SQZYIQrIWx31synSj5E9zNqAWyU=
In-Reply-To: <2023Dec9.081824@mips.complang.tuwien.ac.at>
Content-Language: en-GB
 by: dxf - Sat, 9 Dec 2023 08:52 UTC

On 9/12/2023 6:18 pm, Anton Ertl wrote:
> dxf <dxforth@gmail.com> writes:
>> A program that relies on an 'ambiguous condition' can hardly be portable.
>
> That depends on the ambiguous condition. In particular, looking at
> <https://forth-standard.org/standard/doc#subsection.4.1.2>, I see
>
> |producing a result out of range, e.g., multiplication (using *)
> |results in a value too big to be represented by a single-cell integer
> |(6.1.0090 *, 6.1.0100 */, 6.1.0110 */MOD, 6.1.0570 >NUMBER, 6.1.1561
> |FM/MOD, 6.1.2214 SM/REM, 6.1.2370 UM/MOD, 8.6.1.1820 M*/);
>
> Certainly for * every system with a given cell size produces the same
> result. This has led to the result of * overflow being standardized
> in the next release <http://www.forth200x.org/twos-complement.html>.
> It's interesting that this ambiguous condition does not mention +, -,
> or it's variants.
>
> Bottom line: In some cases there is common practice even if it has not
> been standardized.
>
> I don't think that the documentation in 4.1.2 is useful to find such
> common practice, though.

It was 'ambiguous' because the result was mathematically incorrect.
You can prescribe the actions taken but it won't change the fact.

> ...
> In any case, Forth-94 and Forth-2012 require standard systems to
> document some ambiguous conditions. As you point out, that certainly
> does not help in writing portable programs.

Unfortunately ANS (aka ANS-FORTH) was more interested including as many
systems under their umbrella than they were in users writing portable
programs.

Re: Documenting system-specific behavior

<2023Dec9.122432@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.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: Documenting system-specific behavior
Date: Sat, 09 Dec 2023 11:24:32 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 45
Message-ID: <2023Dec9.122432@mips.complang.tuwien.ac.at>
References: <uilq87$2tvlh$1@dont-email.me> <ujdjoi$3tiit$1@dont-email.me> <m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me> <ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at> <uks326$176qs$1@dont-email.me> <d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com> <ukteh9$1dfna$1@dont-email.me> <ukuquj$1muv1$1@dont-email.me> <ukuv6l$1nmr2$1@dont-email.me> <ul0q90$23j65$1@dont-email.me> <2023Dec9.081824@mips.complang.tuwien.ac.at> <ul19rn$254ed$1@dont-email.me>
Injection-Info: dont-email.me; posting-host="81982e2b7fe220322b820553c5d7fd2f";
logging-data="2312489"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zamNc5go6bLBtYOS/hu8p"
Cancel-Lock: sha1:WRRGo0ucJlUmYPPOPJPvm51kRu8=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 9 Dec 2023 11:24 UTC

dxf <dxforth@gmail.com> writes:
>On 9/12/2023 6:18 pm, Anton Ertl wrote:
>> That depends on the ambiguous condition. In particular, looking at
>> <https://forth-standard.org/standard/doc#subsection.4.1.2>, I see
>>
>> |producing a result out of range, e.g., multiplication (using *)
>> |results in a value too big to be represented by a single-cell integer
>> |(6.1.0090 *, 6.1.0100 */, 6.1.0110 */MOD, 6.1.0570 >NUMBER, 6.1.1561
>> |FM/MOD, 6.1.2214 SM/REM, 6.1.2370 UM/MOD, 8.6.1.1820 M*/);
>>
>> Certainly for * every system with a given cell size produces the same
>> result. This has led to the result of * overflow being standardized
>> in the next release <http://www.forth200x.org/twos-complement.html>.
>> It's interesting that this ambiguous condition does not mention +, -,
>> or it's variants.
>>
>> Bottom line: In some cases there is common practice even if it has not
>> been standardized.
>>
>> I don't think that the documentation in 4.1.2 is useful to find such
>> common practice, though.
>
>It was 'ambiguous' because the result was mathematically incorrect.

Where do I find the documentation on the reasons for this ambiguous
condition that your claim is based on?

I don't have such documentation, so I can only guess. And my guess is
that it's because Forth-94 allowed systems to choose among three
different representations of negative numbers: 2's-complement,
1s-complement, sign-magnitude. And these representations result in
different behaviour on overflow, so the easiest way was to declare
this to be an ambiguous condition.

In any case, it does not matter whether you consider the result to be
"mathematically incorrect", modulo arithmetic produces results that
are useful for some applications (e.g., for hash functions), so given
that it is common practice, it is a good idea to standardize it.

- 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: Documenting system-specific behavior

<ul1m1g$26mt3$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dxforth@gmail.com (dxf)
Newsgroups: comp.lang.forth
Subject: Re: Documenting system-specific behavior
Date: Sat, 9 Dec 2023 23:20:01 +1100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <ul1m1g$26mt3$1@dont-email.me>
References: <uilq87$2tvlh$1@dont-email.me> <ujdjoi$3tiit$1@dont-email.me>
<m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me>
<ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at>
<uks326$176qs$1@dont-email.me>
<d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com>
<ukteh9$1dfna$1@dont-email.me> <ukuquj$1muv1$1@dont-email.me>
<ukuv6l$1nmr2$1@dont-email.me> <ul0q90$23j65$1@dont-email.me>
<2023Dec9.081824@mips.complang.tuwien.ac.at> <ul19rn$254ed$1@dont-email.me>
<2023Dec9.122432@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 9 Dec 2023 12:20:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="883f75cd70374a3bca36277a430e074b";
logging-data="2317219"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YqvkfJXnOVP0VzPmBdV7w"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:nlGLTl65YLpVExc8MK9UZsDrPF8=
Content-Language: en-GB
In-Reply-To: <2023Dec9.122432@mips.complang.tuwien.ac.at>
 by: dxf - Sat, 9 Dec 2023 12:20 UTC

On 9/12/2023 10:24 pm, Anton Ertl wrote:
> dxf <dxforth@gmail.com> writes:
>> On 9/12/2023 6:18 pm, Anton Ertl wrote:
>>> That depends on the ambiguous condition. In particular, looking at
>>> <https://forth-standard.org/standard/doc#subsection.4.1.2>, I see
>>>
>>> |producing a result out of range, e.g., multiplication (using *)
>>> |results in a value too big to be represented by a single-cell integer
>>> |(6.1.0090 *, 6.1.0100 */, 6.1.0110 */MOD, 6.1.0570 >NUMBER, 6.1.1561
>>> |FM/MOD, 6.1.2214 SM/REM, 6.1.2370 UM/MOD, 8.6.1.1820 M*/);
>>>
>>> Certainly for * every system with a given cell size produces the same
>>> result. This has led to the result of * overflow being standardized
>>> in the next release <http://www.forth200x.org/twos-complement.html>.
>>> It's interesting that this ambiguous condition does not mention +, -,
>>> or it's variants.
>>>
>>> Bottom line: In some cases there is common practice even if it has not
>>> been standardized.
>>>
>>> I don't think that the documentation in 4.1.2 is useful to find such
>>> common practice, though.
>>
>> It was 'ambiguous' because the result was mathematically incorrect.
>
> Where do I find the documentation on the reasons for this ambiguous
> condition that your claim is based on?

From the link you provided:

4.1.2 Ambiguous conditions
...
producing a result out of range, e.g., multiplication (using *) results
in a value too big to be represented by a single-cell integer

>
> I don't have such documentation, so I can only guess. And my guess is
> that it's because Forth-94 allowed systems to choose among three
> different representations of negative numbers: 2's-complement,
> 1s-complement, sign-magnitude. And these representations result in
> different behaviour on overflow, so the easiest way was to declare
> this to be an ambiguous condition.
>
> In any case, it does not matter whether you consider the result to be
> "mathematically incorrect", modulo arithmetic produces results that
> are useful for some applications (e.g., for hash functions), so given
> that it is common practice, it is a good idea to standardize it.

And the result will still be 'out of range' which qualifies it as an
'ambiguous condition' under ANS' definition of the term.

Re: FOR-EACH ... DO[ ... ]NEXT

<ul5967$2qirl$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pinka@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: FOR-EACH ... DO[ ... ]NEXT
Date: Mon, 11 Dec 2023 01:05:11 +0400
Organization: A noiseless patient Spider
Lines: 80
Message-ID: <ul5967$2qirl$1@dont-email.me>
References: <uilq87$2tvlh$1@dont-email.me>
<2023Nov14.183012@mips.complang.tuwien.ac.at> <uj2rs1$1qftu$1@dont-email.me>
<2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me>
<m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me>
<ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at>
<uks326$176qs$1@dont-email.me>
<d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com>
<ukteh9$1dfna$1@dont-email.me>
<eca9d334109ee6b72ce83a7b0b754f74@news.novabbs.com>
<ukuj3k$1lkdh$1@dont-email.me> <ukus7r$1n9tc$1@dont-email.me>
<ukvvg6$1sd77$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 10 Dec 2023 21:05:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8d1bb60ac9d5725efd10d31b14c44033";
logging-data="2968437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9X59Mr8MBvrxLvOLKLe5E"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:9ByB5ZNQrA4CdXfaFYYeHXuFFxs=
Content-Language: en-US
In-Reply-To: <ukvvg6$1sd77$1@dont-email.me>
 by: Ruvim - Sun, 10 Dec 2023 21:05 UTC

On 2023-12-09 00:49, Gerry Jackson wrote:
> On 08/12/2023 10:47, Ruvim wrote:
>> On 2023-12-08 12:11, Gerry Jackson wrote:
>> [...]
>>>
>>> Two things about FOR-EACH I don't think I've yet mentioned.
>>>
>>> The pipeline operator is optional. Without it the whole thing reverts
>>> to a BEGIN ... WHILE ... REPEAT loop with a small amount of redundant
>>> code. So why use FOR-EACH, IMHO the FOR-EACH is arguably more readable.
>>>
>>> The pipeline operator can make the FOR-EACH statement equivalent to
>>> multi-WHILE loops without the drawbacks of ELSE parts being separated
>>> in the source code.
>>
>> OTOH, FOR-EACH part is also optional. A pipeline operator can be used
>> instead:
>>
>>    FOR-EACH TRUE DO[ next-item |> check-item |> process-item ]NEXT
>>
>> It's not obvious to me that placing "next-item" into a separate
>> section rather than into the chain (like in this example) makes
>> readability better.
>
> You're probably right, my intention was to highlight that the first item
> had to be something that iterated through a collection. But without
> thinking it through I guess that's a fairly minor change to make. It
> would also eliminate the need for DO[
>
>>
>> Also, I would use different operators to break and to continue the
>> loop, instead of different signs of the input value.
>>
>
> Do you mean three operators that could be placed between the pipeline
> operations i.e. retaining the
>    iterator pipe-operator operation pipe-operator ... sequence
>
> where we have three different pipe operators that, for the sake of
> argument, might be:
>
>    |>  for Proceed currently handled by a value 0
>   <|x  for exit pipeline back, currently <0, like C continue
>    |x> for exit pipeline forward, currently >0, like C break

>
> But without thinking about it deeply I don't see how that would work as
> the decision about which option to take is at run-time not compile-time.
>
> Whether this is managed by conditional jumps or possibly quotations ISTM
> that there is always a choice of 1 from 3 has to be made at runtime.
>
> Or did you have another idea in mind?
>

I mean a compile-time decision. My arguments are as follows.

1. In most use cases, you know at compile-time whether you need to
continue or break the loop (I mean, in the case of a pipeline break).
Then, it's better for readability to use different pipe-operators for
these cases.

2. For code reuse, it's better if an operation returns (and a
pipe-operator accepts) a value of one of two disjoint types {0, x/0},
rather than one of three disjoint types {0, +n/0, -n/0} (where 0 is a
singleton {"0"}, and "\" means a set difference).

If a pipe-operator distinguishes two types of the input value, two
operators are enough. And if we use zero to break a pipeline, these
operators can be defined via your "|>" as follows:

: |>| ( 0|x -- ) postpone 0= postpone |> ; immediate
: |<| ( 0|x -- ) postpone 0= postpone abs postpone |> ; immediate

--
Ruvim

Re: FOR-EACH ... DO[ ... ]NEXT

<nnd$50d1238c$5277ae6b@1a0889fc833ae972>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
Subject: Re: FOR-EACH ... DO[ ... ]NEXT
References: <uilq87$2tvlh$1@dont-email.me> <ukus7r$1n9tc$1@dont-email.me> <ukvvg6$1sd77$1@dont-email.me> <ul5967$2qirl$1@dont-email.me>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$50d1238c$5277ae6b@1a0889fc833ae972>
Organization: KPN B.V.
Date: Mon, 11 Dec 2023 11:19:21 +0100
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!eternal-september.org!news.mixmin.net!weretis.net!feeder8.news.weretis.net!npeer.as286.net!npeer-ng0.as286.net!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe004.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 95
Injection-Date: Mon, 11 Dec 2023 11:19:21 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 4525
 by: none - Mon, 11 Dec 2023 10:19 UTC

In article <ul5967$2qirl$1@dont-email.me>,
Ruvim <ruvim.pinka@gmail.com> wrote:
>On 2023-12-09 00:49, Gerry Jackson wrote:
>> On 08/12/2023 10:47, Ruvim wrote:
>>> On 2023-12-08 12:11, Gerry Jackson wrote:
>>> [...]
>>>>
>>>> Two things about FOR-EACH I don't think I've yet mentioned.
>>>>
>>>> The pipeline operator is optional. Without it the whole thing reverts
>>>> to a BEGIN ... WHILE ... REPEAT loop with a small amount of redundant
>>>> code. So why use FOR-EACH, IMHO the FOR-EACH is arguably more readable.
>>>>
>>>> The pipeline operator can make the FOR-EACH statement equivalent to
>>>> multi-WHILE loops without the drawbacks of ELSE parts being separated
>>>> in the source code.
>>>
>>> OTOH, FOR-EACH part is also optional. A pipeline operator can be used
>>> instead:
>>>
>>>    FOR-EACH TRUE DO[ next-item |> check-item |> process-item ]NEXT
>>>
>>> It's not obvious to me that placing "next-item" into a separate
>>> section rather than into the chain (like in this example) makes
>>> readability better.
>>
>> You're probably right, my intention was to highlight that the first item
>> had to be something that iterated through a collection. But without
>> thinking it through I guess that's a fairly minor change to make. It
>> would also eliminate the need for DO[
>>
>>>
>>> Also, I would use different operators to break and to continue the
>>> loop, instead of different signs of the input value.
>>>
>>
>> Do you mean three operators that could be placed between the pipeline
>> operations i.e. retaining the
>>    iterator pipe-operator operation pipe-operator ... sequence
>>
>> where we have three different pipe operators that, for the sake of
>> argument, might be:
>>
>>    |>  for Proceed currently handled by a value 0
>>   <|x  for exit pipeline back, currently <0, like C continue
>>    |x> for exit pipeline forward, currently >0, like C break
>
>>
>> But without thinking about it deeply I don't see how that would work as
>> the decision about which option to take is at run-time not compile-time.
>>
>> Whether this is managed by conditional jumps or possibly quotations ISTM
>> that there is always a choice of 1 from 3 has to be made at runtime.
>>
>> Or did you have another idea in mind?
>>
>
>
>I mean a compile-time decision. My arguments are as follows.
>
>1. In most use cases, you know at compile-time whether you need to
>continue or break the loop (I mean, in the case of a pipeline break).
>Then, it's better for readability to use different pipe-operators for
>these cases.
>
>2. For code reuse, it's better if an operation returns (and a
>pipe-operator accepts) a value of one of two disjoint types {0, x/0},
>rather than one of three disjoint types {0, +n/0, -n/0} (where 0 is a
>singleton {"0"}, and "\" means a set difference).
>
>
>If a pipe-operator distinguishes two types of the input value, two
>operators are enough. And if we use zero to break a pipeline, these
>operators can be defined via your "|>" as follows:
>
> : |>| ( 0|x -- ) postpone 0= postpone |> ; immediate
> : |<| ( 0|x -- ) postpone 0= postpone abs postpone |> ; immediate

Components of a pipe line must not contain logic to decide when to
stop. It should terminate as the input terminates.
So pipeline operators should marry a yield operation that produces a
stream of data, and decides termination.

>
>
>
>--
>Ruvim
--
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: FOR-EACH ... DO[ ... ]NEXT

<ce3c1b80-2bd6-485a-ad6e-b544cfac4e56@swldwa.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: do-not-use@swldwa.uk (Gerry Jackson)
Newsgroups: comp.lang.forth
Subject: Re: FOR-EACH ... DO[ ... ]NEXT
Date: Wed, 13 Dec 2023 21:47:17 +0000
Organization: A noiseless patient Spider
Lines: 95
Message-ID: <ce3c1b80-2bd6-485a-ad6e-b544cfac4e56@swldwa.uk>
References: <uilq87$2tvlh$1@dont-email.me>
<2023Nov14.183012@mips.complang.tuwien.ac.at> <uj2rs1$1qftu$1@dont-email.me>
<2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me>
<m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me>
<ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at>
<uks326$176qs$1@dont-email.me>
<d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com>
<ukteh9$1dfna$1@dont-email.me>
<eca9d334109ee6b72ce83a7b0b754f74@news.novabbs.com>
<ukuj3k$1lkdh$1@dont-email.me> <ukus7r$1n9tc$1@dont-email.me>
<ukvvg6$1sd77$1@dont-email.me> <ul5967$2qirl$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="c0931136e0840677ab1d080c8c180b3e";
logging-data="1067252"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19RF1GlP95473U1aK1Xl91sS+tlLBk0MRU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:4weIDW7Q7UlD8fY9Q/gOaUm6ukg=
Content-Language: en-GB
In-Reply-To: <ul5967$2qirl$1@dont-email.me>
 by: Gerry Jackson - Wed, 13 Dec 2023 21:47 UTC

On 10/12/2023 21:05, Ruvim wrote:
> On 2023-12-09 00:49, Gerry Jackson wrote:
>> On 08/12/2023 10:47, Ruvim wrote:
>>> On 2023-12-08 12:11, Gerry Jackson wrote:
>>> [...]
>>>>
>>>> Two things about FOR-EACH I don't think I've yet mentioned.
>>>>
>>>> The pipeline operator is optional. Without it the whole thing
>>>> reverts to a BEGIN ... WHILE ... REPEAT loop with a small amount of
>>>> redundant code. So why use FOR-EACH, IMHO the FOR-EACH is arguably
>>>> more readable.
>>>>
>>>> The pipeline operator can make the FOR-EACH statement equivalent to
>>>> multi-WHILE loops without the drawbacks of ELSE parts being
>>>> separated in the source code.
>>>
>>> OTOH, FOR-EACH part is also optional. A pipeline operator can be used
>>> instead:
>>>
>>>    FOR-EACH TRUE DO[ next-item |> check-item |> process-item ]NEXT
>>>
>>> It's not obvious to me that placing "next-item" into a separate
>>> section rather than into the chain (like in this example) makes
>>> readability better.
>>
>> You're probably right, my intention was to highlight that the first
>> item had to be something that iterated through a collection. But
>> without thinking it through I guess that's a fairly minor change to
>> make. It would also eliminate the need for DO[
>>
>>>
>>> Also, I would use different operators to break and to continue the
>>> loop, instead of different signs of the input value.
>>>
>>
>> Do you mean three operators that could be placed between the pipeline
>> operations i.e. retaining the
>>     iterator pipe-operator operation pipe-operator ... sequence
>>
>> where we have three different pipe operators that, for the sake of
>> argument, might be:
>>
>>     |>  for Proceed currently handled by a value 0
>>    <|x  for exit pipeline back, currently <0, like C continue
>>     |x> for exit pipeline forward, currently >0, like C break
>
>>
>> But without thinking about it deeply I don't see how that would work
>> as the decision about which option to take is at run-time not
>> compile-time.
>>
>> Whether this is managed by conditional jumps or possibly quotations
>> ISTM that there is always a choice of 1 from 3 has to be made at runtime.
>>
>> Or did you have another idea in mind?
>>
>
>
> I mean a compile-time decision. My arguments are as follows.
>
> 1. In most use cases, you know at compile-time whether you need to
> continue or break the loop (I mean, in the case of a pipeline break).
> Then, it's better for readability to use different pipe-operators for
> these cases.
>
> 2. For code reuse, it's better if an operation returns (and a
> pipe-operator accepts) a value of one of two disjoint types {0, x/0},
> rather than one of three disjoint types {0, +n/0, -n/0}  (where 0 is a
> singleton {"0"}, and "\" means a set difference).

Why do you say that's better for code reuse?

>
>
> If a pipe-operator distinguishes two types of the input value, two
> operators are enough. And if we use zero to break a pipeline, these
> operators can be defined via your "|>" as follows:
>
>   : |>|  ( 0|x -- ) postpone 0= postpone |> ; immediate
>   : |<|  ( 0|x -- ) postpone 0= postpone abs postpone |> ; immediate
>

Thanks for that. I'm not convinced that your suggestion is better for
readability. Defining suitable constants for pipeline break and continue
might suffice.

However I will experiment with your suggestions, including removing DO[
so that the iterator is the start of the pipeline, when I get a bit more
time. I'm committed to doing some work on a website I help to maintain
for the next few weeks (programming in PHP) so it won't be until next year.

--
Gerry

Re: FOR-EACH ... DO[ ... ]NEXT

<nnd$46aa01b1$22ce9a16@98c43956ef3e3602>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Date: Fri, 15 Dec 2023 18:24:11 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: FOR-EACH ... DO[ ... ]NEXT
Content-Language: en-US
Newsgroups: comp.lang.forth
References: <uilq87$2tvlh$1@dont-email.me>
<2023Nov14.183012@mips.complang.tuwien.ac.at> <uj2rs1$1qftu$1@dont-email.me>
<2023Nov15.185706@mips.complang.tuwien.ac.at> <ujdjoi$3tiit$1@dont-email.me>
<m27cmcjtqj.fsf@gmail.com> <uk4k6k$8n7t$1@dont-email.me>
<ukqmj2$tha8$1@dont-email.me> <2023Dec7.075413@mips.complang.tuwien.ac.at>
<uks326$176qs$1@dont-email.me>
<d22ffeb29d29adc18a2449405aa0f7a6@news.novabbs.com>
<ukteh9$1dfna$1@dont-email.me>
<eca9d334109ee6b72ce83a7b0b754f74@news.novabbs.com>
<ukuj3k$1lkdh$1@dont-email.me> <ukus7r$1n9tc$1@dont-email.me>
<ukvvg6$1sd77$1@dont-email.me> <ul5967$2qirl$1@dont-email.me>
<ce3c1b80-2bd6-485a-ad6e-b544cfac4e56@swldwa.uk>
From: the.beez.speaks@gmail.com (Hans Bezemer)
In-Reply-To: <ce3c1b80-2bd6-485a-ad6e-b544cfac4e56@swldwa.uk>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$46aa01b1$22ce9a16@98c43956ef3e3602>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!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: 42
Injection-Date: Fri, 15 Dec 2023 18:24:11 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2610
 by: Hans Bezemer - Fri, 15 Dec 2023 17:24 UTC

On 13-12-2023 22:47, Gerry Jackson wrote:
OK, I made a high level Forth version WITH size.
You only get the address, that's it.

It's full of 4tH-isms, but I guess one will manage.

[UNDEFINED] foreach [IF]
\ 'f ( addr --)
: foreach ( 'f addr count size -- )
tuck * >r -rot r> bounds ?do
i over execute over ( size 'f size)
+loop drop drop ( --)
;

\ 'f ( st addr -- st')
: reduce ( st 'f addr count size -- st')
tuck * >r -rot >r rot r> r> bounds ?do
over i swap execute >r over r> swap
+loop nip nip ( st')
;

aka foreach map
[THEN]

struct
field: one
field: two
end-struct /bla

6 constant #bla

#bla /bla * array bla
[: dup bla - swap -> two ! ;] bla #bla /bla foreach
[: -> two ? ;] bla #bla /bla foreach depth . cr
[: -> two dup @ dup * swap ! ;] bla #bla /bla map depth . cr
[: -> two ? ;] bla #bla /bla foreach depth . cr
0 [: -> two @ + ;] bla #bla /bla reduce . depth .

Hans Bezemer

Re: FOR-EACH ... DO[ ... ]NEXT

<nnd$6fbda40e$581da2df@0a677966def62035>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Newsgroups: comp.lang.forth
References: <uilq87$2tvlh$1@dont-email.me> <ul5967$2qirl$1@dont-email.me> <ce3c1b80-2bd6-485a-ad6e-b544cfac4e56@swldwa.uk> <nnd$46aa01b1$22ce9a16@98c43956ef3e3602>
Subject: Re: FOR-EACH ... DO[ ... ]NEXT
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$6fbda40e$581da2df@0a677966def62035>
Organization: KPN B.V.
Date: Sat, 16 Dec 2023 12:02:55 +0100
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!usenet.csail.mit.edu!nntp.TheWorld.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe005.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 52
Injection-Date: Sat, 16 Dec 2023 12:02:55 +0100
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: none - Sat, 16 Dec 2023 11:02 UTC

In article <nnd$46aa01b1$22ce9a16@98c43956ef3e3602>,
Hans Bezemer <the.beez.speaks@gmail.com> wrote:
>On 13-12-2023 22:47, Gerry Jackson wrote:
>OK, I made a high level Forth version WITH size.
>You only get the address, that's it.
>
>It's full of 4tH-isms, but I guess one will manage.
>
>[UNDEFINED] foreach [IF]
>\ 'f ( addr --)
>: foreach ( 'f addr count size -- )
> tuck * >r -rot r> bounds ?do
> i over execute over ( size 'f size)
> +loop drop drop ( --)
>;
>
>\ 'f ( st addr -- st')
>: reduce ( st 'f addr count size -- st')
> tuck * >r -rot >r rot r> r> bounds ?do
> over i swap execute >r over r> swap
> +loop nip nip ( st')
>;
>
>aka foreach map
>[THEN]
>
>struct
> field: one
> field: two
>end-struct /bla
>
>6 constant #bla
>
>#bla /bla * array bla
>[: dup bla - swap -> two ! ;] bla #bla /bla foreach
>[: -> two ? ;] bla #bla /bla foreach depth . cr
>[: -> two dup @ dup * swap ! ;] bla #bla /bla map depth . cr
>[: -> two ? ;] bla #bla /bla foreach depth . cr
>0 [: -> two @ + ;] bla #bla /bla reduce . depth .

If you show a test, show the result of the test.

>
>Hans Bezemer

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 -

Pages:123
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor