Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #45582
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: 8th version of "create... does>" |
| Date | 2016-02-16 16:34 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2016Feb16.173433@mips.complang.tuwien.ac.at> (permalink) |
| References | <n9uvpq$gur$1@dont-email.me> <KZadnaZ99qHVrl7LnZ2dnUU7-S2dnZ2d@supernews.com> <n9vc8s$smk$1@dont-email.me> |
Ron Aaron <rambamist@gmail.com> writes:
>
>
>On 16/02/2016 16:33, Andrew Haley wrote:
>
>> That's not wildly different from polyFORTH II, which had USE:
>>
>> CREATE FOO ... blah ... <address> USE
>>
>> USE takes the address of some runtime code and patches it into the
>> code field of the most recent definition. I think that syntax is a
>> little more pleasant than your above.
The Gforth development version has SET-DOES>, which is similar to the
USE above. E.g.:
: constant ( n "name" -- )
create , ['] @ set-does> ;
>Yes, the syntax is a bit nicer. On the other hand, I strongly want to
>avoid "fixing up" code as much as possible. Such things can be too
>easily used to subvert code, which is counter to 8th's design goals.
Moreover, the fixing up is hard to implement in Forth systems that
directly compile to flash. In
<http://www.complang.tuwien.ac.at/anton/euroforth/ef15/papers/ertl.pdf>
I suggest a word DOES-CREATE that does both at once. The example
above would become
: const ( n "name" -- )
['] @ does-create , ;
Thinking about it again, I am wondering, though. We also have
SET-OPTIMIZER (which changes what COMPILE, does), and this is also
used as a fixup; e.g.:
: constant ( n "name" -- )
\ you must not change the body of "name"
create ,
['] @ set-does>
[: >body @ postpone literal ;] set-optimizer ;
And we have an implementation where we have a special "current-word"
structure that can be changed up to the next definition and is then
frozen in order to share data between similar words (and then we have
thought about unfreezing words, changing them, and refreezing them);
so the fixup approach also causes problems for RAM-based systems;
maybe we could solve these problems by doing the setup first, and then
creating the word with a header that does not need further fixups;
maybe something like:
: constant ( n "name" -- )
\ you must not change the body of "name"
['] @ next-does>
[: >body @ postpone literal ;] next-optimizer
create , ;
- 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 2015: http://www.rigwit.co.uk/EuroForth2015/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
8th version of "create... does>" Ron Aaron <rambamist@gmail.com> - 2016-02-16 13:08 +0200
Re: 8th version of "create... does>" Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-02-16 08:33 -0600
Re: 8th version of "create... does>" Ron Aaron <rambamist@gmail.com> - 2016-02-16 16:41 +0200
Re: 8th version of "create... does>" Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-02-16 08:44 -0600
Re: 8th version of "create... does>" anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-16 16:34 +0000
Re: 8th version of "create... does>" Ron Aaron <rambamist@gmail.com> - 2016-02-16 19:31 +0200
Re: 8th version of "create... does>" anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-17 17:10 +0000
csiph-web