Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Star Trek Lives!


devel / comp.lang.forth / Re: colon-semicolon convention and create-does

SubjectAuthor
* for what is need the word CREATE?Timur Aksenov
+* Re: for what is need the word CREATE?dxforth
|`* Re: for what is need the word CREATE?Hugh Aguilar
| `* Re: for what is need the word CREATE?dxforth
|  `* Re: for what is need the word CREATE?Hugh Aguilar
|   `- Re: for what is need the word CREATE?dxforth
`* Re: for what is need the word CREATE?Ruvim
 `* Re: for what is need the word CREATE?dxforth
  `* colon-semicolon convention and create-does (was: for what is need theRuvim
   +* Re: colon-semicolon convention and create-does (was: for what is need the word CAnton Ertl
   |`* Re: colon-semicolon convention and create-does (was: for what is needRuvim
   | `- Re: colon-semicolon convention and create-does (was: for what is need the word CAnton Ertl
   `* Re: colon-semicolon convention and create-does (was: for what is needdxforth
    +* Re: colon-semicolon convention and create-does (was: for what is need the word CAnton Ertl
    |`- Re: colon-semicolon convention and create-does (was: for what is needdxforth
    `* Re: colon-semicolon convention and create-does (was: for what is needRuvim
     `* Re: colon-semicolon convention and create-does (was: for what is needdxforth
      `* Re: colon-semicolon convention and create-doesRuvim
       +* Re: colon-semicolon convention and create-doesdxforth
       |`- Re: colon-semicolon convention and create-doesRuvim
       `* Re: colon-semicolon convention and create-doesAnton Ertl
        +* Re: colon-semicolon convention and create-doesRuvim
        |`* Re: colon-semicolon convention and create-doesAnton Ertl
        | `* Re: colon-semicolon convention and create-doesRuvim
        |  `* Re: colon-semicolon convention and create-doesAnton Ertl
        |   `* Re: colon-semicolon convention and create-doesRuvim
        |    +* Re: colon-semicolon convention and create-doesdxforth
        |    |`* Re: colon-semicolon convention and create-doesdxforth
        |    | `* Re: colon-semicolon convention and create-doesRuvim
        |    |  `* Re: colon-semicolon convention and create-doesdxforth
        |    |   +* Re: colon-semicolon convention and create-doesRuvim
        |    |   |`* Re: colon-semicolon convention and create-doesdxforth
        |    |   | `* Re: colon-semicolon convention and create-doesRuvim
        |    |   |  `* Re: colon-semicolon convention and create-doesdxforth
        |    |   |   `* Re: colon-semicolon convention and create-doesAnton Ertl
        |    |   |    `* Re: colon-semicolon convention and create-doesdxforth
        |    |   |     `* Re: colon-semicolon convention and create-doesAnton Ertl
        |    |   |      `* Re: colon-semicolon convention and create-doesdxforth
        |    |   |       `- Re: colon-semicolon convention and create-doesAnton Ertl
        |    |   `* DOES> vs. SET-DOES> (was: colon-semicolon convention and create-does)Anton Ertl
        |    |    `- Re: DOES> vs. SET-DOES> (was: colon-semicolon convention anddxforth
        |    `* Re: colon-semicolon convention and create-doesAnton Ertl
        |     `* Re: colon-semicolon convention and create-doesRuvim
        |      `- Re: colon-semicolon convention and create-doesPaul Rubin
        `- Re: colon-semicolon convention and create-doesHugh Aguilar

Pages:12
Re: colon-semicolon convention and create-does

<2021Aug23.110835@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Mon, 23 Aug 2021 09:08:35 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 96
Message-ID: <2021Aug23.110835@mips.complang.tuwien.ac.at>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com> <sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org> <sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org> <sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org> <sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at> <sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at> <sfu8iq$clp$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="9650f806d0ce2f552fb764fd1a77c29f";
logging-data="27152"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iN1LsZzGgqxFsgUdKLKdp"
Cancel-Lock: sha1:UfaXsoNEWykj/G+qtCsKWcXyW68=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 23 Aug 2021 09:08 UTC

Ruvim <ruvim.pinka@gmail.com> writes:
>On 2021-08-22 19:55, Anton Ertl wrote:
>> Ruvim <ruvim.pinka@gmail.com> writes:
>>> On 2021-08-22 08:29, Anton Ertl wrote:
>>>> Ruvim <ruvim.pinka@gmail.com> writes:
>>>>> DOES ( xt -- )
>>>>
>>>> Already exists under the name SET-DOES> in Gforth.
>>>
>>> Yes, I see. I wonder whether it can be easily implemented in any Forth
>>> system that provides "does>".
>>
>> Not that I can see.
>
>I didn't mean in a standard way, but in some system specific way (using
>carnal knowledge).
>
>An inefficient straightforward implementation could be something like this:
>
> : does ( xt -- )
> >r :noname postpone does> r> compile, postpone ;
> get-current latest-name-in last !
> execute
> ;

And maybe change the section before and restore it afterwards. After
all, you want this to work:

: const ( n "name" -- )
create ['] @ does , ;

(and on many systems, DOES would put the noname definition between the
NAME header and the n deposited with ",").

Sure, system-specific implementations are possible and not
particularly hard. In Gforth we have replaced the original (dodoes)
routine (which performs a call to a threaded-code address) with one
that was originally called (dodoesxt) (which EXECUTEs an xt instead);
the latter has been renamed into (dodoes) after we removed the old
one. There is SET-DOES>, of course.

And there is an implementation of DOES> that is based on SET-DOES> and
quotations, and that's the most complicated part of the whole thing. Hmm, now I am wondering why we did not do it as follows:

: does>
lit compile, here >r 0 , postpone set-does> postpone ;
:noname lastxt r> ! ; immediate

Probably to support interpretive DOES>.

>>> Concerning compiling to flash, I don't see how it can be justified.
>>
>> There are lots of microcontrollers with lots of flash and little RAM.
>>
>>> AFAIK, a more often scenario is that you prepare one image that is
>>> written to many devices (and you don't have a compiler on each device).
>>
>> Not having a compiler is beyond the standard. In that case you can
>> also put restrictions on executions of DOES> (doing the standard thing
>> for DOES> won't bring you back under the standard umbrella).
>>
>>> But even if it's only one device, the approach with image seems to be
>>> more robust and more forward-thinking.
>>
>> What approach is that?
>
>I'm not an expert in this area. But just as far as I understand it.
>
>By the "approach with image" I meant that a Forth system compiles a
>program and prepares a completed image in RAM, and then this image is
>entirely written (by this Forth system, or by other means) into the
>flash memory, instead of incremental compiling the program into the
>flash memory at once.

I.e., the classical cross-compiling approach that C gives you, too.
This gets rid of a strength of Forth: Interactivity. Sure, you can
then have some text interpreter where you can type in commands, but
you no longer have full programmability at your fingertips; and every
time you want the slightest change to the program, you have to
terminate the session, recompile, and reflash, and start another
session, rather than, e.g., just adding a word and redirecting a hook
to use that word.

Gforth has such a cross compiler (and others, too, I guess), but we
only use it for bootstrapping (and others, too, I guess). For
experiencing the benefits of Forth, you need a proper Forth system,
either in the target (as, e.g., Mecrisp does), or distributed between
host and target (as the tethered/umbilical systems of commercial
vendors do).

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: colon-semicolon convention and create-does

<sg0hqq$11l$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Mon, 23 Aug 2021 19:19:36 +0300
Organization: A noiseless patient Spider
Lines: 192
Message-ID: <sg0hqq$11l$1@dont-email.me>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 23 Aug 2021 16:19:38 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="00e2e37df4aa4a0e927971bce3f6b4cc";
logging-data="1077"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YLN6g+0AzGgGVspiHQUPS"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:MIhvby9vAKBh8GZ9+EW2lj3eBts=
In-Reply-To: <2021Aug23.110835@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ruvim - Mon, 23 Aug 2021 16:19 UTC

On 2021-08-23 12:08, Anton Ertl wrote:
> Ruvim <ruvim.pinka@gmail.com> writes:
>> On 2021-08-22 19:55, Anton Ertl wrote:
>>> Ruvim <ruvim.pinka@gmail.com> writes:
>>>> On 2021-08-22 08:29, Anton Ertl wrote:
>>>>> Ruvim <ruvim.pinka@gmail.com> writes:
>>>>>> DOES ( xt -- )
>>>>>
>>>>> Already exists under the name SET-DOES> in Gforth.
>>>>
>>>> Yes, I see. I wonder whether it can be easily implemented in any Forth
>>>> system that provides "does>".
>>>
>>> Not that I can see.
>>
>> I didn't mean in a standard way, but in some system specific way (using
>> carnal knowledge).
>>
>> An inefficient straightforward implementation could be something like this:
>>
>> : does ( xt -- )
>> >r :noname postpone does> r> compile, postpone ;
>> get-current latest-name-in last !
>> execute
>> ;
>
> And maybe change the section before and restore it afterwards. After
> all, you want this to work:
>
> : const ( n "name" -- )
> create ['] @ does , ;
>
> (and on many systems, DOES would put the noname definition between the
> NAME header and the n deposited with ",").

Yes, it will break contiguity of the data field (if the system doesn't
support multiple sections/dictionaries, or "does" doesn't use it).

But according to my specification, it's allowed to do it: DOES may
allocate memory in data space. So, it's incorrect to perform DOES before
allocating the data filed.

A correct variant:

: const ( n "name" -- )
create , ['] @ does ;

So this "does" imposes some restrictions on programs that "does>"
doesn't impose (hence, without tightening the specification, it's
impossible to define the standard "does>" via this "does" in a standard
way).

OTOH, this "does" removes some other restrictions that "does>" imposes.

For example, the following should work:

create x 123 , [: ( addr -- ) @ . ;] does
x \ prints 123

Compared to "does>", this "does" has the following advantages: simpler
specification, easier comprehension, possibility to use outside of
definitions, better factoring, no ambiguity with "recurse".

> Sure, system-specific implementations are possible and not
> particularly hard. In Gforth we have replaced the original (dodoes)
> routine (which performs a call to a threaded-code address) with one
> that was originally called (dodoesxt) (which EXECUTEs an xt instead);
> the latter has been renamed into (dodoes) after we removed the old
> one. There is SET-DOES>, of course.
>
> And there is an implementation of DOES> that is based on SET-DOES> and
> quotations, and that's the most complicated part of the whole thing.
> Hmm, now I am wondering why we did not do it as follows:
>
> : does>
> lit compile, here >r 0 , postpone set-does> postpone ;
> :noname lastxt r> ! ; immediate

I implemented "does>" in a similar way (https://git.io/JEO7W).

The functionality to defer a literal is so useful sometimes that I
introduced a special word for that:

lit-deferred, ( -- addr )
Reserve one cell of data space and place its address on the stack.
Append to the current definition the following Run-time semantics.
Run-Time: place a single-cell number from addr on the stack.

In Gforth this word can be defined as

: lit-deferred, ( -- addr ) ['] lit compile, here 0 , ;

A more portable definition (but still non standard):

: lit-deferred, ( -- addr ) ( run-time: -- x )
postpone ahead here >r 0 , postpone then
r> dup lit, ['] @ compile,
;

>
> Probably to support interpretive DOES>.

Actually, the interpretation semantics are simpler than the compilation
semantics: you need just start the new anonymous definition and use its
xt for "set-does>":

: does>
state @ if postpone does> exit then
lastnt @ >r
depth >r :noname depth r> - 1- roll ( ... xt )
r> lastnt !
set-does>
; immediate

But in Gforth it requires to save and restore "lastnt", that is used by
"set-does>" and changed by ":noname". That's why I prefer to use the
compilation word list to find the latest word.

>>>> Concerning compiling to flash, I don't see how it can be justified.
>>>
>>> There are lots of microcontrollers with lots of flash and little RAM.
>>>
>>>> AFAIK, a more often scenario is that you prepare one image that is
>>>> written to many devices (and you don't have a compiler on each device).
>>>
>>> Not having a compiler is beyond the standard. In that case you can
>>> also put restrictions on executions of DOES> (doing the standard thing
>>> for DOES> won't bring you back under the standard umbrella).
>>>
>>>> But even if it's only one device, the approach with image seems to be
>>>> more robust and more forward-thinking.
>>>
>>> What approach is that?
>>
>> I'm not an expert in this area. But just as far as I understand it.
>>
>> By the "approach with image" I meant that a Forth system compiles a
>> program and prepares a completed image in RAM, and then this image is
>> entirely written (by this Forth system, or by other means) into the
>> flash memory, instead of incremental compiling the program into the
>> flash memory at once.
>
> I.e., the classical cross-compiling approach that C gives you, too.
> This gets rid of a strength of Forth: Interactivity. Sure, you can
> then have some text interpreter where you can type in commands, but
> you no longer have full programmability at your fingertips; and every
> time you want the slightest change to the program, you have to
> terminate the session, recompile, and reflash, and start another
> session, rather than, e.g., just adding a word and redirecting a hook
> to use that word.

I see, but it's not necessary.

New words can be compiled into RAM (i.e., just another
section/dictionary). And the corresponding image can be prepared and
written into the flash memory in the same interactive session too.

The difference is that in one approach you should use NEXT-IMMEDIATE and
other special words to generate immutable code at once (what about word
list structures?), in another approach you need to enter one special
command (SAVE-FLASH for example) when you are ready to save the result
of your interactive work. (Although, I guess, more often you will
recompile the whole program from the updated sources to update the flash
memory after your debugging session)

> Gforth has such a cross compiler (and others, too, I guess), but we
> only use it for bootstrapping (and others, too, I guess). For
> experiencing the benefits of Forth, you need a proper Forth system,
> either in the target (as, e.g., Mecrisp does), or distributed between
> host and target (as the tethered/umbilical systems of commercial
> vendors do).

Yes, certainly you need it.

The question is how to cope with the FLASH memory, that cannot be easy
writable.

--
Ruvim

Re: colon-semicolon convention and create-does

<sg0lj3$1nvo$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Tue, 24 Aug 2021 03:23:45 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sg0lj3$1nvo$1@gioia.aioe.org>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="57336"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Mon, 23 Aug 2021 17:23 UTC

On 24/08/2021 02:19, Ruvim wrote:
> On 2021-08-23 12:08, Anton Ertl wrote:
>> Ruvim <ruvim.pinka@gmail.com> writes:
>>> On 2021-08-22 19:55, Anton Ertl wrote:
>>>> Ruvim <ruvim.pinka@gmail.com> writes:
>>>>> On 2021-08-22 08:29, Anton Ertl wrote:
>>>>>> Ruvim <ruvim.pinka@gmail.com> writes:
>>>>>>> DOES ( xt -- )
>>>>>>
>>>>>> Already exists under the name SET-DOES> in Gforth.
>>>>>
>>>>> Yes, I see. I wonder whether it can be easily implemented in any Forth
>>>>> system that provides "does>".
>>>>
>>>> Not that I can see.
>>>
>>> I didn't mean in a standard way, but in some system specific way (using
>>> carnal knowledge).
>>>
>>> An inefficient straightforward implementation could be something like this:
>>>
>>> : does ( xt -- )
>>> >r :noname postpone does> r> compile, postpone ;
>>> get-current latest-name-in last !
>>> execute
>>> ;
>>
>> And maybe change the section before and restore it afterwards. After
>> all, you want this to work:
>>
>> : const ( n "name" -- )
>> create ['] @ does , ;
>>
>> (and on many systems, DOES would put the noname definition between the
>> NAME header and the n deposited with ",").
>
> Yes, it will break contiguity of the data field (if the system doesn't
> support multiple sections/dictionaries, or "does" doesn't use it).
>
> But according to my specification, it's allowed to do it: DOES may
> allocate memory in data space. So, it's incorrect to perform DOES before
> allocating the data filed.
>
> A correct variant:
>
> : const ( n "name" -- )
> create , ['] @ does ;
>

Your spec includes a pointless dependency on CREATE

: const ( n "name" -- )
['] @ does , ;

Re: colon-semicolon convention and create-does

<2021Aug23.191911@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Mon, 23 Aug 2021 17:19:11 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 70
Message-ID: <2021Aug23.191911@mips.complang.tuwien.ac.at>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com> <sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org> <sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org> <sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org> <sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at> <sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at> <sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at> <sg0hqq$11l$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="9650f806d0ce2f552fb764fd1a77c29f";
logging-data="10547"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ZHYr9+hkY8N6Q2wBjDK12"
Cancel-Lock: sha1:QCKoa5V/hhhMZBQlI+AeyvgRxkw=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 23 Aug 2021 17:19 UTC

Ruvim <ruvim.pinka@gmail.com> writes:
>But according to my specification, it's allowed to do it: DOES may
>allocate memory in data space. So, it's incorrect to perform DOES before
>allocating the data filed.

SET-DOES> does not have this restriction, and I think you should avoid
littering the Forth system with such restrictions. We see people fall
into such traps regularly.

>> Hmm, now I am wondering why we did not do it as follows:
>>
>> : does>
>> lit compile, here >r 0 , postpone set-does> postpone ;
>> :noname lastxt r> ! ; immediate
....
>> Probably to support interpretive DOES>.
>
>Actually, the interpretation semantics are simpler than the compilation
>semantics: you need just start the new anonymous definition and use its
>xt for "set-does>":
>
> : does>
> state @ if postpone does> exit then
> lastnt @ >r
> depth >r :noname depth r> - 1- roll ( ... xt )
> r> lastnt !
> set-does>
> ; immediate

Ugh! This is fugly, as Andrew Haley might express it.

More along the lines of:

: int-does>
latestxt >r noname : latestxt r> make-latest dup set-does> make-latest ;

: comp-does>
postpone lit here >r 0 , postpone set-does> postpone ;
noname : lastxt r> ! ; immediate

' int-does> ' comp-does> interpret/compile: does>

Which does not answer the question of why we implemented it with
quotations.

>New words can be compiled into RAM (i.e., just another
>section/dictionary).

These microcontrollers have very little RAM. This RAM is filled with
data for variables and such. No place for colon definitions. E.g.,
the MSP430G2553 has 16KB of Flash and 512B of RAM. Also, the transfer
to flash would incur extra complexity, in particular code relocation.

>The difference is that in one approach you should use NEXT-IMMEDIATE and
>other special words to generate immutable code at once

As mentioned, they solved it in other ways.

>(what about word
>list structures?)

What about them? I dimly remember that Mecrisp wordlists are chained
in the opposite way, but I don't remember why.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: colon-semicolon convention and create-does

<sg25ih$o9m$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Tue, 24 Aug 2021 10:02:41 +0300
Organization: A noiseless patient Spider
Lines: 113
Message-ID: <sg25ih$o9m$1@dont-email.me>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me> <2021Aug23.191911@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 24 Aug 2021 07:02:42 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9fb4dea20e517977d7099d5f5fe84918";
logging-data="24886"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Ll2HVqSbGdrHXG0es/yDt"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:EoMujXFTEZKVCPSCODzjetxF3bI=
In-Reply-To: <2021Aug23.191911@mips.complang.tuwien.ac.at>
Content-Language: en-US
X-Mozilla-News-Host: news://nntp.aioe.org
 by: Ruvim - Tue, 24 Aug 2021 07:02 UTC

On 2021-08-23 20:19, Anton Ertl wrote:
> Ruvim <ruvim.pinka@gmail.com> writes:
>> But according to my specification, it's allowed to do it: DOES may
>> allocate memory in data space. So, it's incorrect to perform DOES before
>> allocating the data filed.
>
> SET-DOES> does not have this restriction, and I think you should avoid
> littering the Forth system with such restrictions. We see people fall
> into such traps regularly.

This restriction can be removed. It just provides more options to
implementors.

>>> Hmm, now I am wondering why we did not do it as follows:
>>>
>>> : does>
>>> lit compile, here >r 0 , postpone set-does> postpone ;
>>> :noname lastxt r> ! ; immediate
> ...
>>> Probably to support interpretive DOES>.
>>
>> Actually, the interpretation semantics are simpler than the compilation
>> semantics: you need just start the new anonymous definition and use its
>> xt for "set-does>":
>>
>> : does>
>> state @ if postpone does> exit then
>> lastnt @ >r
>> depth >r :noname depth r> - 1- roll ( ... xt )
>> r> lastnt !
>> set-does>
>> ; immediate
>
> Ugh! This is fugly, as Andrew Haley might express it.
>
> More along the lines of:
>
> : int-does>
> latestxt >r noname : latestxt r> make-latest dup set-does> make-latest ;

Well, this variant just relies on more pieces of carnal knowledge.

In my framework (see https://git.io/JG12K) this definition could be
expressed even more elegant:

: int-does> :noname end{ end set-does } ;

> : comp-does>
> postpone lit here >r 0 , postpone set-does> postpone ;
> noname : lastxt r> ! ; immediate
>
> ' int-does> ' comp-does> interpret/compile: does>
>
> Which does not answer the question of why we implemented it with
> quotations.

Probably, the reason is that your implementation with quotations
(https://git.io/JEssF) doesn't require the trick with a deferred literal.

In my framework a quotation-based variant could be expressed as the
following:

: comp-does> postpone [: end{ end postpone set-does end } ;

>> New words can be compiled into RAM (i.e., just another
>> section/dictionary).
>
> These microcontrollers have very little RAM. This RAM is filled with
> data for variables and such. No place for colon definitions. E.g.,
> the MSP430G2553 has 16KB of Flash and 512B of RAM.

Oh, there is no chance to compile into RAM in such a case.

> Also, the transfer
> to flash would incur extra complexity, in particular code relocation.

AFAIK, this problem was already solved many times (if you have enough RAM).

>> The difference is that in one approach you should use NEXT-IMMEDIATE and
>> other special words to generate immutable code at once
>
> As mentioned, they solved it in other ways.

It's interesting how they do incremental compilation into Flash (if any).

>> (what about word list structures?)
>
> What about them?

I mean, how to update the head of the compilation word list, and the
pointer of the dictionary (data space)? (I suppose, they are kept in
flash memory).

If you can update them, then you can update a word header by usual
IMMEDIATE too.

> I dimly remember that Mecrisp wordlists are chained
> in the opposite way, but I don't remember why.

--
Ruvim

Re: colon-semicolon convention and create-does

<874kbfi9gq.fsf@nightsong.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Tue, 24 Aug 2021 00:32:37 -0700
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <874kbfi9gq.fsf@nightsong.com>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me>
<2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me>
<2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me>
<2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me>
<2021Aug23.191911@mips.complang.tuwien.ac.at>
<sg25ih$o9m$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4536200c1a688dafa299984a89812376";
logging-data="1688"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oRTcMnjh2Xzkl1eum2YC7"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:V1JdUh6Gr59AkVKo+yCdSd1ZtnU=
sha1:m7iJzllQHFgaCXDGxw/Ka3ln/dY=
 by: Paul Rubin - Tue, 24 Aug 2021 07:32 UTC

Ruvim <ruvim.pinka@gmail.com> writes:
> I mean, how to update the head of the compilation word list, and the
> pointer of the dictionary (data space)? (I suppose, they are kept in
> flash memory).

I haven't looked, but I assumed that the system reserved a few ram cells
for stuff like that. I do think these sorts of processors are valid
Forth use cases, and it is worthwhile to find and maybe standardize good
approaches to them. Flashforth, Mecrisp, and I think Amforth all have
their own ways to deal with compiling to flash.

Re: colon-semicolon convention and create-does

<sg295i$lfm$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Tue, 24 Aug 2021 18:04:01 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sg295i$lfm$1@gioia.aioe.org>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org>
<sg25q9$pqf$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="22006"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Tue, 24 Aug 2021 08:04 UTC

On 24/08/2021 17:06, Ruvim wrote:
> On 2021-08-23 20:23, dxforth wrote:
>> On 24/08/2021 02:19, Ruvim wrote:
> [...]
>>> But according to my specification, it's allowed to do it: DOES may
>>> allocate memory in data space. So, it's incorrect to perform DOES before
>>> allocating the data filed.
>>>
>>> A correct variant:
>>>
>>>     : const ( n "name" -- )
>>>       create , ['] @ does ;
>>>
>>
>> Your spec includes a pointless dependency on CREATE
>
> Since it was an alternative/replacement for "does>" only.

DOES> doesn't require an xt as a parameter

>
>
>>
>>      : const ( n "name" -- )
>>        ['] @ does , ;
>>
>
> It's better to use another name for such a word.
>
> But anyway, it's unclear to me why "does" ( xt -- )
> is better than "create-does" ( xt "name" -- )

It's not. What's unnecessary given xt, is CREATE to generate a
name and run-time with the behaviour of CREATE, and another word
to modify it to the required xt.

Re: colon-semicolon convention and create-does

<sg2epu$5mn$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Tue, 24 Aug 2021 12:40:12 +0300
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <sg2epu$5mn$1@dont-email.me>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org>
<sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Aug 2021 09:40:14 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9fb4dea20e517977d7099d5f5fe84918";
logging-data="5847"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+oOMjZ8SgLQvKGfs1nSLkl"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:Jqv/iUvOS2f4MzKg3MH5HJd/fCE=
In-Reply-To: <sg295i$lfm$1@gioia.aioe.org>
Content-Language: en-US
 by: Ruvim - Tue, 24 Aug 2021 09:40 UTC

On 2021-08-24 11:04, dxforth wrote:
> On 24/08/2021 17:06, Ruvim wrote:
>> On 2021-08-23 20:23, dxforth wrote:
>>> On 24/08/2021 02:19, Ruvim wrote:
>> [...]
>>>> But according to my specification, it's allowed to do it: DOES may
>>>> allocate memory in data space. So, it's incorrect to perform DOES
>>>> before
>>>> allocating the data filed.
>>>>
>>>> A correct variant:
>>>>
>>>>     : const ( n "name" -- )
>>>>       create , ['] @ does ;
>>>>
>>>
>>> Your spec includes a pointless dependency on CREATE
>>
>> Since it was an alternative/replacement for "does>" only.
>
> DOES> doesn't require an xt as a parameter

It doesn't matter.
"does" can be implemented in such a way (without the mentioned
limitation on programs) that any use of:
does> ... ;
can be replaced by:
[: ... ;] does ;

>>>
>>>       : const ( n "name" -- )
>>>         ['] @ does , ;
>>>
>>
>> It's better to use another name for such a word.
>>
>> But anyway, it's unclear to me why "does" ( xt -- )
>> is better than "create-does" ( xt "name" -- )
>
> It's not.  What's unnecessary given xt, is CREATE to generate a
> name and run-time with the behaviour of CREATE, and another word
> to modify it to the required xt.

From an API point of view it's even better to take the name as an
argument from the stack:

created-does ( sd-name xt -- )

And then the pattern

... create xxx does> yyy ;

can be replaced by

... parse-name [: yyy ;] created-does xxx

But perhaps some use cases exist when "does>" or "does" cannot be
*easily* replaced by "created-does" ( sd-name xt -- ). Could anybody
provide such examples?

By the way, "created-does" can be implemented in a standard way as:

: created-does ( sd-name xt -- )
>r :noname postpone does> r> compile, postpone ; >r
['] create execute-parsing r> execute
;

And vise versa, "create" and "does" can be implemented in a standard way
via "created-does" (and "does>" via "does").

Certainly, such implementations are not so efficient as system-specific
variants can be.

--
Ruvim

Re: colon-semicolon convention and create-does

<sg2m6b$10kj$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Tue, 24 Aug 2021 21:46:19 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sg2m6b$10kj$1@gioia.aioe.org>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org>
<sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org>
<sg2epu$5mn$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="33427"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Tue, 24 Aug 2021 11:46 UTC

On 24/08/2021 19:40, Ruvim wrote:
> On 2021-08-24 11:04, dxforth wrote:
>> On 24/08/2021 17:06, Ruvim wrote:
>>> On 2021-08-23 20:23, dxforth wrote:
>>>> On 24/08/2021 02:19, Ruvim wrote:
>>> [...]
>>>>> But according to my specification, it's allowed to do it: DOES may
>>>>> allocate memory in data space. So, it's incorrect to perform DOES
>>>>> before
>>>>> allocating the data filed.
>>>>>
>>>>> A correct variant:
>>>>>
>>>>>     : const ( n "name" -- )
>>>>>       create , ['] @ does ;
>>>>>
>>>>
>>>> Your spec includes a pointless dependency on CREATE
>>>
>>> Since it was an alternative/replacement for "does>" only.
>>
>> DOES> doesn't require an xt as a parameter
>
> It doesn't matter.
> "does" can be implemented in such a way (without the mentioned
> limitation on programs) that any use of:
> does> ... ;
> can be replaced by:
> [: ... ;] does ;

Apart from finding a use for quotations, what else does it do
that DOES> cannot?

>
>
>>>>
>>>>       : const ( n "name" -- )
>>>>         ['] @ does , ;
>>>>
>>>
>>> It's better to use another name for such a word.
>>>
>>> But anyway, it's unclear to me why "does" ( xt -- )
>>> is better than "create-does" ( xt "name" -- )
>>
>> It's not.  What's unnecessary given xt, is CREATE to generate a
>> name and run-time with the behaviour of CREATE, and another word
>> to modify it to the required xt.
>
>
> From an API point of view it's even better to take the name as an
> argument from the stack:
>
> created-does ( sd-name xt -- )
>
> And then the pattern
>
> ... create xxx does> yyy ;
>
> can be replaced by
>
> ... parse-name [: yyy ;] created-does xxx
>
> But perhaps some use cases exist when "does>" or "does" cannot be
> *easily* replaced by "created-does" ( sd-name xt -- ). Could anybody
> provide such examples?

First step is to provide examples of use - why it's in anybody's
interest to replace definers which have worked for 99% of users.

Re: colon-semicolon convention and create-does

<sg2prl$mb8$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Tue, 24 Aug 2021 15:48:52 +0300
Organization: A noiseless patient Spider
Lines: 93
Message-ID: <sg2prl$mb8$1@dont-email.me>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org>
<sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org>
<sg2epu$5mn$1@dont-email.me> <sg2m6b$10kj$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Aug 2021 12:48:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9fb4dea20e517977d7099d5f5fe84918";
logging-data="22888"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190EpmeOVgx4+oDxDvlJJ3O"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:ln1MZELViz2nG62MNT6CsKZmVKw=
In-Reply-To: <sg2m6b$10kj$1@gioia.aioe.org>
Content-Language: en-US
 by: Ruvim - Tue, 24 Aug 2021 12:48 UTC

On 2021-08-24 14:46, dxforth wrote:
> On 24/08/2021 19:40, Ruvim wrote:
>> On 2021-08-24 11:04, dxforth wrote:
>>> On 24/08/2021 17:06, Ruvim wrote:
>>>> On 2021-08-23 20:23, dxforth wrote:
>>>>> On 24/08/2021 02:19, Ruvim wrote:
>>>> [...]
>>>>>> But according to my specification, it's allowed to do it: DOES may
>>>>>> allocate memory in data space. So, it's incorrect to perform DOES
>>>>>> before
>>>>>> allocating the data filed.
>>>>>>
>>>>>> A correct variant:
>>>>>>
>>>>>>     : const ( n "name" -- )
>>>>>>       create , ['] @ does ;
>>>>>>
>>>>>
>>>>> Your spec includes a pointless dependency on CREATE
>>>>
>>>> Since it was an alternative/replacement for "does>" only.
>>>
>>> DOES> doesn't require an xt as a parameter
>>
>> It doesn't matter.
>> "does" can be implemented in such a way (without the mentioned
>> limitation on programs) that any use of:
>>     does> ... ;
>> can be replaced by:
>>     [: ... ;] does ;
>
> Apart from finding a use for quotations, what else does it do
> that DOES> cannot?

I already wrote this yesterday (see news:sg0hqq$11l$1@dont-email.me)

Compared to "does>", this "does" has the following advantages:
- simpler specification,
- easier comprehension,
- possibility to use outside of definitions,
- better factoring,
- no ambiguity with "recurse".

[...]
>>>>
>>>> But anyway, it's unclear to me why "does" ( xt -- )
>>>> is better than "create-does" ( xt "name" -- )
>>>
>>> It's not.  What's unnecessary given xt, is CREATE to generate a
>>> name and run-time with the behaviour of CREATE, and another word
>>> to modify it to the required xt.
>>
>>
>>   From an API point of view it's even better to take the name as an
>> argument from the stack:
>>
>>     created-does ( sd-name xt -- )
>>
>> And then the pattern
>>
>>     ... create  xxx does> yyy ;
>>
>> can be replaced by
>>
>>     ... parse-name [: yyy ;] created-does xxx
>>
>> But perhaps some use cases exist when "does>" or "does" cannot be
>> *easily* replaced by "created-does" ( sd-name xt -- ). Could anybody
>> provide such examples?
>
> First step is to provide examples of use - why it's in anybody's
> interest to replace definers which have worked for 99% of users.

There is no any interest to replace them in old programs. An interest
can be to implement such new word in a system and use it in new
programs. Also, an interest can be to promote better practices.

The initial problems was about interpretive "does>" and about difficult
comprehension of "does>" for newbies (both users and implementers).
From this point of view a new word can be an alternative to classic
"does>".

I think, we should admit that "does>" is a bad designed thing (probably
it was invented with a close connection to some particular
implementation of threaded code). The specification for "does>" just
cries about it: https://forth-standard.org/standard/core/DOES

--
Ruvim

Re: colon-semicolon convention and create-does

<sg4cui$qvh$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Wed, 25 Aug 2021 13:20:50 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sg4cui$qvh$1@gioia.aioe.org>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org>
<sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org>
<sg2epu$5mn$1@dont-email.me> <sg2m6b$10kj$1@gioia.aioe.org>
<sg2prl$mb8$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="27633"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Wed, 25 Aug 2021 03:20 UTC

On 24/08/2021 22:48, Ruvim wrote:
> On 2021-08-24 14:46, dxforth wrote:
>> On 24/08/2021 19:40, Ruvim wrote:
>>> On 2021-08-24 11:04, dxforth wrote:
>>>> On 24/08/2021 17:06, Ruvim wrote:
>>> ...
>>> It doesn't matter.
>>> "does" can be implemented in such a way (without the mentioned
>>> limitation on programs) that any use of:
>>>     does> ... ;
>>> can be replaced by:
>>>     [: ... ;] does ;
>>
>> Apart from finding a use for quotations, what else does it do
>> that DOES> cannot?
>
> I already wrote this yesterday (see news:sg0hqq$11l$1@dont-email.me)
>
> Compared to "does>", this "does" has the following advantages:
> - simpler specification,
> - easier comprehension,
> - possibility to use outside of definitions,
> - better factoring,
> - no ambiguity with "recurse".

DOES> can be used outside a definition; and there's nothing stopping
DOES> ... ; executing a word that's recursive as unusual as that's been.
'Easy' isn't a tag I would apply to a definer that was originally a
mishmash of ideas and it's proposed to complicate further by forcing
users into quotations which they didn't need before.

> ...
> I think, we should admit that "does>" is a bad designed thing (probably
> it was invented with a close connection to some particular
> implementation of threaded code). The specification for "does>" just
> cries about it: https://forth-standard.org/standard/core/DOES

For all its quirks CREATE DOES> has been used in environments as demanding
as target compilation. So clearly it is usable. Short of a massive change
to how forth is currently being used, proposing new definers on theoretical
grounds is likely to fall on deaf ears. That's not to say you can't take
forth in a direction that suits you.

Re: colon-semicolon convention and create-does

<sg59u2$b7k$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Wed, 25 Aug 2021 14:35:27 +0300
Organization: A noiseless patient Spider
Lines: 73
Message-ID: <sg59u2$b7k$1@dont-email.me>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org>
<sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org>
<sg2epu$5mn$1@dont-email.me> <sg2m6b$10kj$1@gioia.aioe.org>
<sg2prl$mb8$1@dont-email.me> <sg4cui$qvh$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 25 Aug 2021 11:35:30 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="844bd085d5782e78c69eacf1e1b2785b";
logging-data="11508"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192nPrxZzJ/H7AD/BhISl7n"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Cancel-Lock: sha1:kltYuCEU6f7BhImdFBly49HPej8=
In-Reply-To: <sg4cui$qvh$1@gioia.aioe.org>
Content-Language: en-US
 by: Ruvim - Wed, 25 Aug 2021 11:35 UTC

On 2021-08-25 06:20, dxforth wrote:
> On 24/08/2021 22:48, Ruvim wrote:
>> On 2021-08-24 14:46, dxforth wrote:
>>> On 24/08/2021 19:40, Ruvim wrote:
>>>> On 2021-08-24 11:04, dxforth wrote:
>>>>> On 24/08/2021 17:06, Ruvim wrote:
>>>> ...
>>>> It doesn't matter.
>>>> "does" can be implemented in such a way (without the mentioned
>>>> limitation on programs) that any use of:
>>>>     does> ... ;
>>>> can be replaced by:
>>>>     [: ... ;] does ;
>>>
>>> Apart from finding a use for quotations, what else does it do
>>> that DOES> cannot?
>>
>> I already wrote this yesterday (see news:sg0hqq$11l$1@dont-email.me)
>>
>> Compared to "does>", this "does" has the following advantages:
>>     - simpler specification,
>>     - easier comprehension,
>>     - possibility to use outside of definitions,
>>     - better factoring,
>>     - no ambiguity with "recurse".
>
> DOES> can be used outside a definition;

What do you mean?

Interpretive "does>" isn't standardized, and it breaks the convention
concerning colon-semicolon that we discussed.

> and there's nothing stopping
> DOES> ... ; executing a word that's recursive as unusual as that's been.

It's a workaround that just confirms the mentioned ambiguity, it doesn't
solve it.

> 'Easy' isn't a tag I would apply to a definer that was originally a
> mishmash of ideas

But the specification for "does" is really far simpler than for "does>".

> and it's proposed to complicate further by forcing
> users into quotations which they didn't need before.

It doesn't force users to use quotations. You can define a named or
anonymous definition and pass its xt to "does". Although, this way is
longer.

>> ...
>> I think, we should admit that "does>" is a bad designed thing (probably
>> it was invented with a close connection to some particular
>> implementation of threaded code). The specification for "does>" just
>> cries about it: https://forth-standard.org/standard/core/DOES
>
> For all its quirks CREATE DOES> has been used in environments as demanding
> as target compilation.  So clearly it is usable.  Short of a massive change
> to how forth is currently being used, proposing new definers on theoretical
> grounds is likely to fall on deaf ears.  That's not to say you can't take
> forth in a direction that suits you.

Perhaps you are right, but we had to try.

--
Ruvim

DOES> vs. SET-DOES> (was: colon-semicolon convention and create-does)

<2021Aug25.145416@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: DOES> vs. SET-DOES> (was: colon-semicolon convention and create-does)
Date: Wed, 25 Aug 2021 12:54:16 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 97
Message-ID: <2021Aug25.145416@mips.complang.tuwien.ac.at>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com> <sfpsf5$11mu$1@gioia.aioe.org> <sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at> <sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at> <sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at> <sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org> <sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org> <sg2epu$5mn$1@dont-email.me> <sg2m6b$10kj$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="698bda361438bbb368b34d24c14a45d6";
logging-data="26777"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tZwGhqaQxrtXABe2Q7F4M"
Cancel-Lock: sha1:XAegL3oNgdYcOjvhJiPCmgh+XdU=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Wed, 25 Aug 2021 12:54 UTC

dxforth <dxforth@gmail.com> writes:
>Apart from finding a use for quotations, what else does it do
>that DOES> cannot?

Like many other bad factorings, DOES> can do everything that SET-DOES>
can do, it's just that it is more cumbersome and has other disadvantages.

One of the disadvantages of DOES> is that it ends the current
definition. This can result in cumbersome workarounds: E.g., consider
the following definitions from
<http://git.savannah.gnu.org/cgit/gforth.git/tree/compat/struct.fs?id=75fcf9e4159f4c7a71e5d191854e713a72517201>:

: dofield ( -- )
does> ( name execution: addr1 -- addr2 )
@ + ;

: dozerofield ( -- )
immediate
does> ( name execution: -- )
drop ;

: field ( align1 offset1 align size "name" -- align2 offset2 )
\ name execution: addr1 -- addr2
2 pick >r \ this uglyness is just for optimizing with dozerofield
create-field
r> if \ offset<>0
dofield
else
dozerofield
then ;

With SET-DOES>, they can be replaced with:

: field ( align1 offset1 align size "name" -- align2 offset2 )
\ name execution: addr1 -- addr2
2 pick >r \ this uglyness is just for optimizing with dozerofield
create-field
r> if \ offset<>0
[: @ + ;] set-does>
else
immediate ['] drop set-does>
then ;

Or, if you prefer to do without the quotation, you can turn the
quotation into a separate named word, and still be shorter than the
DOES> version.

Another issue is that the implementation of DOES> is more complicated
and bug-prone. I remember at least one bug in DOES> having to do with
"knowing" that the threaded-code address to be stored in the CREATEd
word is so-and-so-many cells after the return address of the DOES>; of
course this offset changed during maintenance.

Another disadvantage of DOES> (at least for non-inlining systems) is
that it performs a call to the code behind the DOES>, and also need to
later return from that call with an explicit or implicit EXIT, even if
there is only a single word between DOES> and ";". With the current
gforth-fast implementation on AMD64, if we count the numbers of
instructions executed starting at the call to FIVE and ending before
the code compiled by the ";" behind, in

: const create , SOME-DOES-CODE ;
5 const five
: foo five ;

for different variants of SOME-DOES-CODE, we get:

insts SOME-DOES-CODE
25 does> @ ;
28 [: @ ;] set-does>
15 ['] @ set-does>

and this 10-instruction advantage over DOES> for calling single words
also applies to any other single word.

Concerning the 3-instruction disadvantage when having to wrap a
sequence of words in a colon definition (quotation or other), this can
be turned into a 3-instruction advantage (at the cost of two
additional threaded-code cells), i.e., 22 instructions for our
example, with a relatively easy optimization. The same
code (3 instructions less, 2 threaded-code cells more) can be produced
for the DOES> variant, though. The bottom line is that SET-DOES>
offers a performance advantage when there is only one word between
DOES> and ";".

>First step is to provide examples of use - why it's in anybody's
>interest to replace definers which have worked for 99% of users.

It's not. If it ain't broken, don't fix it. For new code, though
SET-DOES> can be advantageous, see above.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: DOES> vs. SET-DOES> (was: colon-semicolon convention and create-does)

<sg7036$1aqn$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: DOES> vs. SET-DOES> (was: colon-semicolon convention and
create-does)
Date: Thu, 26 Aug 2021 12:59:50 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sg7036$1aqn$1@gioia.aioe.org>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfpsf5$11mu$1@gioia.aioe.org> <sfrur2$888$1@dont-email.me>
<2021Aug22.072955@mips.complang.tuwien.ac.at> <sftt33$qe6$1@dont-email.me>
<2021Aug22.185556@mips.complang.tuwien.ac.at> <sfu8iq$clp$1@dont-email.me>
<2021Aug23.110835@mips.complang.tuwien.ac.at> <sg0hqq$11l$1@dont-email.me>
<sg0lj3$1nvo$1@gioia.aioe.org> <sg25q9$pqf$1@dont-email.me>
<sg295i$lfm$1@gioia.aioe.org> <sg2epu$5mn$1@dont-email.me>
<sg2m6b$10kj$1@gioia.aioe.org> <2021Aug25.145416@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="43863"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Thu, 26 Aug 2021 02:59 UTC

On 25/08/2021 22:54, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>>Apart from finding a use for quotations, what else does it do
>>that DOES> cannot?
>
> Like many other bad factorings, DOES> can do everything that SET-DOES>
> can do, it's just that it is more cumbersome and has other disadvantages.
> ...
>
>>First step is to provide examples of use - why it's in anybody's
>>interest to replace definers which have worked for 99% of users.
>
> It's not. If it ain't broken, don't fix it. For new code, though
> SET-DOES> can be advantageous, see above.

I'm not here to argue for or against DOES>. I mostly use something
else because my system is unconventional and it worked out simpler
for me. I can't remember when I last used FIELD. Perhaps luck,
as it seems a lot of trouble for what it does. Optimizing the zero
case is more effort than I'd be willing to expend.

Re: colon-semicolon convention and create-does

<sg81nr$p34$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Thu, 26 Aug 2021 22:34:02 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sg81nr$p34$1@gioia.aioe.org>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<sfioev$va2$1@dont-email.me> <sfkj3i$rtr$1@gioia.aioe.org>
<sflnb7$utn$1@dont-email.me> <sfmn1r$sn9$1@gioia.aioe.org>
<sfo8ck$9pk$1@dont-email.me> <sfpsf5$11mu$1@gioia.aioe.org>
<sfrur2$888$1@dont-email.me> <2021Aug22.072955@mips.complang.tuwien.ac.at>
<sftt33$qe6$1@dont-email.me> <2021Aug22.185556@mips.complang.tuwien.ac.at>
<sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at>
<sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org>
<sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org>
<sg2epu$5mn$1@dont-email.me> <sg2m6b$10kj$1@gioia.aioe.org>
<sg2prl$mb8$1@dont-email.me> <sg4cui$qvh$1@gioia.aioe.org>
<sg59u2$b7k$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="25700"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Thu, 26 Aug 2021 12:34 UTC

On 25/08/2021 21:35, Ruvim wrote:
> On 2021-08-25 06:20, dxforth wrote:
>> On 24/08/2021 22:48, Ruvim wrote:
>>> On 2021-08-24 14:46, dxforth wrote:
>>>> On 24/08/2021 19:40, Ruvim wrote:
>>>>> On 2021-08-24 11:04, dxforth wrote:
>>>>>> On 24/08/2021 17:06, Ruvim wrote:
>>>>> ...
>>>>> It doesn't matter.
>>>>> "does" can be implemented in such a way (without the mentioned
>>>>> limitation on programs) that any use of:
>>>>>     does> ... ;
>>>>> can be replaced by:
>>>>>     [: ... ;] does ;
>>>>
>>>> Apart from finding a use for quotations, what else does it do
>>>> that DOES> cannot?
>>>
>>> I already wrote this yesterday (see news:sg0hqq$11l$1@dont-email.me)
>>>
>>> Compared to "does>", this "does" has the following advantages:
>>>     - simpler specification,
>>>     - easier comprehension,
>>>     - possibility to use outside of definitions,
>>>     - better factoring,
>>>     - no ambiguity with "recurse".
>>
>> DOES> can be used outside a definition;
>
> What do you mean?
>
> Interpretive "does>" isn't standardized, and it breaks the convention
> concerning colon-semicolon that we discussed.

I mean outside the stereotypical CREATE DOES> definition.

>
>> and there's nothing stopping
>> DOES> ... ; executing a word that's recursive as unusual as that's been.
>
> It's a workaround that just confirms the mentioned ambiguity, it doesn't
> solve it.

It's a trade-off. Few would argue :NONAME and quotations are ambiguous
relative to named definitions and EXECUTE a workaround. EXECUTE was the
price for namelessness.

A definer which uses xt as a parameter is almost certainly trading away space
compared to CREATE DOES> . This can be observed in the SwiftForth and VFX
implementations of BUILD which I posted some time ago. Accepting everything
comes with a cost, the inability to use RECURSE directly in DOES> ... ; is
one I would pay.

Re: colon-semicolon convention and create-does

<2021Aug26.150832@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Thu, 26 Aug 2021 13:08:32 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 100
Message-ID: <2021Aug26.150832@mips.complang.tuwien.ac.at>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com> <2021Aug22.185556@mips.complang.tuwien.ac.at> <sfu8iq$clp$1@dont-email.me> <2021Aug23.110835@mips.complang.tuwien.ac.at> <sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org> <sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org> <sg2epu$5mn$1@dont-email.me> <sg2m6b$10kj$1@gioia.aioe.org> <sg2prl$mb8$1@dont-email.me> <sg4cui$qvh$1@gioia.aioe.org> <sg59u2$b7k$1@dont-email.me> <sg81nr$p34$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="ff08170ccd53084ca1988404d186c4b9";
logging-data="18669"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iQgkW3DljZ1c2pT6ucKyt"
Cancel-Lock: sha1:lkLGGvMdDgvQXqmBeOcj1bakbSY=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Thu, 26 Aug 2021 13:08 UTC

dxforth <dxforth@gmail.com> writes:
>A definer which uses xt as a parameter is almost certainly trading away space
>compared to CREATE DOES> .

Let's see:

: myconst1 create , does> @ ;
: myconst2 create , ['] @ set-does> ;

gforth 0.7.2 Gforth 0.7.9_20210819:
(no set-does>): (has set-does>)
simple-see myconst1 simple-see myconst2
$7FD0A592B1B0 call $7FC64B2EBD50 call
$7FD0A592B1B8 <Create> $7FC64B2EBD58 <Create>
$7FD0A592B1C0 call $7FC64B2EBD60 call
$7FD0A592B1C8 <,> $7FC64B2EBD68 <,>
$7FD0A592B1D0 lit $7FC64B2EBD70 lit
$7FD0A592B1D8 <140534107779576> $7FC64B2EBD78 @
$7FD0A592B1E0 call $7FC64B2EBD80 call
$7FD0A592B1E8 <(does>2)> $7FC64B2EBD88 <set-does>>
$7FD0A592B1F0 ;s $7FC64B2EBD90 ;s
$7FD0A592B1F8 <7378697629483820646>
$7FD0A592B200 <7378697629483820646>
$7FD0A592B208 @
$7FD0A592B210 ;s ok

I.e., DOES> costs 4 cells more.

Ok, you might say that's the best case for SET-DOES>, so let's compare
a best case for DOES>:

: mydefer1 create ['] noop , does> @ execute ;
: mydefer2 create ['] noop , [: @ execute ;] set-does> ;

gforth 0.7.2 Gforth 0.7.9_20210819:
(no set-does>): (has set-does>)
simple-see mydefer1 simple-see mydefer2 (and the quotation)
$7FD0A592B240 call $7FC64B2EBE40 call
$7FD0A592B248 <Create> $7FC64B2EBE48 <Create>
$7FD0A592B250 lit $7FC64B2EBE50 lit
$7FD0A592B258 noop $7FC64B2EBE58 noop
$7FD0A592B260 call $7FC64B2EBE60 call
$7FD0A592B268 <,> $7FC64B2EBE68 <,>
$7FD0A592B270 lit $7FC64B2EBE70 lit
$7FD0A592B278 <140534107779736> $7FC64B2EBE78 $7FC64B065CF8
$7FD0A592B280 call $7FC64B2EBE80 call
$7FD0A592B288 <(does>2)> $7FC64B2EBE88 <set-does>>
$7FD0A592B290 ;s $7FC64B2EBE90 ;s ok
$7FD0A592B298 <-7647121087922341905> $7FC64B065CF0 <(UValue)+$A8>
$7FD0A592B2A0 <-5283570396732524545> $7FC64B065CF8 $4048C8
$7FD0A592B2A8 @ $7FC64B065D00 @
$7FD0A592B2B0 execute $7FC64B065D08 execute
$7FD0A592B2B8 ;s ok $7FC64B065D10 ;s ok

So even in the best case for DOES>, DOES> uses the same threaded-code
space as SET-DOES>.

- anton

This can be observed in the SwiftForth and VFX
>implementations of BUILD which I posted some time ago. Accepting everything
>comes with a cost, the inability to use RECURSE directly in DOES> ... ; is
>one I would pay.

--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: colon-semicolon convention and create-does

<sg9iir$5om$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Fri, 27 Aug 2021 12:27:39 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sg9iir$5om$1@gioia.aioe.org>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<2021Aug22.185556@mips.complang.tuwien.ac.at> <sfu8iq$clp$1@dont-email.me>
<2021Aug23.110835@mips.complang.tuwien.ac.at> <sg0hqq$11l$1@dont-email.me>
<sg0lj3$1nvo$1@gioia.aioe.org> <sg25q9$pqf$1@dont-email.me>
<sg295i$lfm$1@gioia.aioe.org> <sg2epu$5mn$1@dont-email.me>
<sg2m6b$10kj$1@gioia.aioe.org> <sg2prl$mb8$1@dont-email.me>
<sg4cui$qvh$1@gioia.aioe.org> <sg59u2$b7k$1@dont-email.me>
<sg81nr$p34$1@gioia.aioe.org> <2021Aug26.150832@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="5910"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Fri, 27 Aug 2021 02:27 UTC

On 26/08/2021 23:08, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>>A definer which uses xt as a parameter is almost certainly trading away space
>>compared to CREATE DOES> .
>
> Let's see:
>
> : myconst1 create , does> @ ;
> : myconst2 create , ['] @ set-does> ;
>
> gforth 0.7.2 Gforth 0.7.9_20210819:
> (no set-does>): (has set-does>)
> simple-see myconst1 simple-see myconst2
> ...
>
> I.e., DOES> costs 4 cells more.
>
> Ok, you might say that's the best case for SET-DOES>, so let's compare
> a best case for DOES>:
>
> : mydefer1 create ['] noop , does> @ execute ;
> : mydefer2 create ['] noop , [: @ execute ;] set-does> ;
> ...
>
> So even in the best case for DOES>, DOES> uses the same threaded-code
> space as SET-DOES>.

Not quite what I meant but let's go with that.

Best case was where xt represented an existing function. For
the more common case you broke even at the expense of having to
reposition the quotation code after SET-DOES to make it do what
DOES> did naturally without the fuss.

Re: colon-semicolon convention and create-does

<2021Aug27.092248@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Fri, 27 Aug 2021 07:22:48 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 25
Message-ID: <2021Aug27.092248@mips.complang.tuwien.ac.at>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com> <2021Aug23.110835@mips.complang.tuwien.ac.at> <sg0hqq$11l$1@dont-email.me> <sg0lj3$1nvo$1@gioia.aioe.org> <sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org> <sg2epu$5mn$1@dont-email.me> <sg2m6b$10kj$1@gioia.aioe.org> <sg2prl$mb8$1@dont-email.me> <sg4cui$qvh$1@gioia.aioe.org> <sg59u2$b7k$1@dont-email.me> <sg81nr$p34$1@gioia.aioe.org> <2021Aug26.150832@mips.complang.tuwien.ac.at> <sg9iir$5om$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="c7186496f997e847cab40f2f27332733";
logging-data="16394"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ukUT+9zeW9yP2MeV3qw74"
Cancel-Lock: sha1:J+wqiGYOpnJlmlv2XtBv/thw8qg=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 27 Aug 2021 07:22 UTC

dxforth <dxforth@gmail.com> writes:
>On 26/08/2021 23:08, Anton Ertl wrote:
>> dxforth <dxforth@gmail.com> writes:
>>>A definer which uses xt as a parameter is almost certainly trading away space
>>>compared to CREATE DOES> .
....
>Not quite what I meant but let's go with that.

What did you mean?

>Best case was where xt represented an existing function. For
>the more common case you broke even at the expense of having to
>reposition the quotation code after SET-DOES to make it do what
>DOES> did naturally without the fuss.

No repositioning going on. The quotation is in a different section.
I appended the cells for the quotation in the posting to make
comparison easy.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: colon-semicolon convention and create-does

<sgad61$1u86$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Fri, 27 Aug 2021 20:01:37 +1000
Organization: Aioe.org NNTP Server
Message-ID: <sgad61$1u86$1@gioia.aioe.org>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com>
<2021Aug23.110835@mips.complang.tuwien.ac.at> <sg0hqq$11l$1@dont-email.me>
<sg0lj3$1nvo$1@gioia.aioe.org> <sg25q9$pqf$1@dont-email.me>
<sg295i$lfm$1@gioia.aioe.org> <sg2epu$5mn$1@dont-email.me>
<sg2m6b$10kj$1@gioia.aioe.org> <sg2prl$mb8$1@dont-email.me>
<sg4cui$qvh$1@gioia.aioe.org> <sg59u2$b7k$1@dont-email.me>
<sg81nr$p34$1@gioia.aioe.org> <2021Aug26.150832@mips.complang.tuwien.ac.at>
<sg9iir$5om$1@gioia.aioe.org> <2021Aug27.092248@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="63750"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Fri, 27 Aug 2021 10:01 UTC

On 27/08/2021 17:22, Anton Ertl wrote:
> dxforth <dxforth@gmail.com> writes:
>>On 26/08/2021 23:08, Anton Ertl wrote:
>>> dxforth <dxforth@gmail.com> writes:
>>>>A definer which uses xt as a parameter is almost certainly trading away space
>>>>compared to CREATE DOES> .
> ...
>>Not quite what I meant but let's go with that.
>
> What did you mean?

Even my system, which has an efficient xt-based definer, the following
beats it for size:

: m1 constant does> c@ c, ;

If I can't justify ditching DOES> what of systems that never needed
anything else. Indeed, they may count themselves lucky compared to
myself who had no choice but to implement another definer.

>
>>Best case was where xt represented an existing function. For
>>the more common case you broke even at the expense of having to
>>reposition the quotation code after SET-DOES to make it do what
>>DOES> did naturally without the fuss.
>
> No repositioning going on. The quotation is in a different section.
> I appended the cells for the quotation in the posting to make
> comparison easy.

So merely matching DOES> was conditional on quotations being located
somewhere out of the way.

Re: colon-semicolon convention and create-does

<2021Aug27.150033@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: colon-semicolon convention and create-does
Date: Fri, 27 Aug 2021 13:00:33 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 69
Message-ID: <2021Aug27.150033@mips.complang.tuwien.ac.at>
References: <84fcd268-b8a2-44c6-ba1f-9937d9e7d9f3n@googlegroups.com> <sg0lj3$1nvo$1@gioia.aioe.org> <sg25q9$pqf$1@dont-email.me> <sg295i$lfm$1@gioia.aioe.org> <sg2epu$5mn$1@dont-email.me> <sg2m6b$10kj$1@gioia.aioe.org> <sg2prl$mb8$1@dont-email.me> <sg4cui$qvh$1@gioia.aioe.org> <sg59u2$b7k$1@dont-email.me> <sg81nr$p34$1@gioia.aioe.org> <2021Aug26.150832@mips.complang.tuwien.ac.at> <sg9iir$5om$1@gioia.aioe.org> <2021Aug27.092248@mips.complang.tuwien.ac.at> <sgad61$1u86$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="c7186496f997e847cab40f2f27332733";
logging-data="8082"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+E/A9ZilN2vRx4ThXdYukN"
Cancel-Lock: sha1:AWjt2piCxOffaDX2vlP19IpNSxE=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 27 Aug 2021 13:00 UTC

dxforth <dxforth@gmail.com> writes:
>On 27/08/2021 17:22, Anton Ertl wrote:
>> dxforth <dxforth@gmail.com> writes:
>>>On 26/08/2021 23:08, Anton Ertl wrote:
>>>> dxforth <dxforth@gmail.com> writes:
>>>>>A definer which uses xt as a parameter is almost certainly trading away space
>>>>>compared to CREATE DOES> .
>> ...
>>>Not quite what I meant but let's go with that.
>>
>> What did you mean?
>
>Even my system, which has an efficient xt-based definer, the following
>beats it for size:
>
> : m1 constant does> c@ c, ;

What's the point of this example? I have to guess what this means
(and my guess is that it does not work as intended on big-endian
systems). Is your point that on your system DOES> produces smaller
code than your efficient xt-based definer when combined with CONSTANT?

>If I can't justify ditching DOES> what of systems that never needed
>anything else. Indeed, they may count themselves lucky compared to
>myself who had no choice but to implement another definer.

Why did you have no choice?

>> No repositioning going on. The quotation is in a different section.
>> I appended the cells for the quotation in the posting to make
>> comparison easy.
>
>So merely matching DOES> was conditional on quotations being located
>somewhere out of the way.

For this example, yes. OTOH, looking at the FIELD example from
<2021Aug25.145416@mips.complang.tuwien.ac.at> on 64-bit systems.

Gforth 0.7.2 needs 424 bytes of dictionary for the code using DOES>.

Gforth 0.7.9_20210819 needs 240 bytes of dictionary (200 bytes in the
main dictionary and 40 bytes in the next section) for the code using
SET-DOES>.

And if you don't want to implement sections and quotations, you can
write it like this:

: dofield @ + ;

: field ( align1 offset1 align size "name" -- align2 offset2 )
\ name execution: addr1 -- addr2
2 pick >r \ this uglyness is just for optimizing with dozerofield
create-field
r> if \ offset<>0
['] dofield set-does>
else
immediate ['] drop set-does>
then ;

This costs 264 bytes of dictionary on Gforth 0.7.9_20210819.

The additional flexibility of SET-DOES> can lead to smaller code.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor