Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #13442
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: How to use the "compile," word |
| Date | 2012-07-02 16:54 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2012Jul2.185409@mips.complang.tuwien.ac.at> (permalink) |
| References | <fb4d99b3-a0ad-4417-b703-d9809a662b1e@googlegroups.com> <7f1f48a4-8c78-43e1-8c5f-92b185382564@f16g2000yqg.googlegroups.com> <jsq2lo$s0m$1@online.de> |
Bernd Paysan <bernd.paysan@gmx.de> writes:
>BruceMcF wrote:
>
>> On Jun 30, 7:21 pm, teammember0...@gmail.com wrote:
>>> I'm trying to learn how to use the "compile," word. Would anybody
>>> know how to use it? I am interested in example source code. Thanks.
>>
>> Suppose you want to use the file version of S" in a word ~ that is,
>> compile from the input into a buffer, terminated by 0. S" while
>> compiling embeds the string at compile time, but ['] S" should get the
>> file-S" xt, and compiling it with compile, should give the file-S"
>> behavior at runtime:
>>
>> : file-S" ( cccc" -- ca u ) ['] S" COMPILE, ; IMMEDIATE
>
>Don't do this. In Gforth, you get what you read by the letters of the
>standard (this). In VFX Forth, you get the compilation semantics by
>doing so,
Just another bug to fix.
> and in many other Forths, you just get a state-smart word
>compiled into your code.
Which will work in the expected way for his code.
>As the letters of the standard don't describe
>reality, it's probably wiser to adjust the letters instead of adjusting
>reality.
A Forth system has a bug, so let's not fix the bug, but fix the
standard?
>COMPILE, is there to allow you to write a user-written compiler.
A pretty useless exercise, because there are no standard holes (in,
e.g., INCLUDED or EVALUATE) into which you can plug the compiler.
But COMPILE, is useful for other things, e.g., for writing
parameterized code generators. An example is the parser generator
Gray <http://www.complang.tuwien.ac.at/forth/gray.zip>, which contains
several occurences of "COMPILE,". E.g.:
: generate-nt \ -- )
\ generates a call to the code for the rule )
\ since the code needs not be generated yet, an indirect call may be used )
exec dup @ if
@ compile,
else
postpone literal
postpone @
postpone execute
endif ;
- 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 2012: http://www.euroforth.org/ef12/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to use the "compile," word teammember0x01@gmail.com - 2012-06-30 16:21 -0700
Re: How to use the "compile," word BruceMcF <agila61@netscape.net> - 2012-06-30 16:53 -0700
Re: How to use the "compile," word Coos Haak <chforth@hccnet.nl> - 2012-07-01 02:06 +0200
Re: How to use the "compile," word BruceMcF <agila61@netscape.net> - 2012-06-30 19:11 -0700
Re: How to use the "compile," word Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-01 19:50 +0200
Re: How to use the "compile," word "Elizabeth D. Rather" <erather@forth.com> - 2012-07-01 08:40 -1000
Re: How to use the "compile," word Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-01 23:14 +0200
Re: How to use the "compile," word BruceMcF <agila61@netscape.net> - 2012-07-01 15:38 -0700
Re: How to use the "compile," word Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-02 01:18 +0200
Re: How to use the "compile," word anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-02 17:03 +0000
Re: How to use the "compile," word Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-02 21:39 +0200
Re: How to use the "compile," word anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-03 16:55 +0000
Re: How to use the "compile," word Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-03 23:09 +0200
Re: How to use the "compile," word BruceMcF <agila61@netscape.net> - 2012-07-02 12:00 -0700
Re: How to use the "compile," word Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-02 22:44 +0200
Re: How to use the "compile," word Josh Grams <josh@qualdan.com> - 2012-07-02 20:18 +0000
Re: How to use the "compile," word Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-02 22:53 +0200
Re: How to use the "compile," word anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-02 16:54 +0000
Re: How to use the "compile," word Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-02 13:05 -0500
Re: How to use the "compile," word anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-03 16:08 +0000
Re: How to use the "compile," word Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-03 14:35 -0500
Re: How to use the "compile," word Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-02 21:03 +0200
Re: How to use the "compile," word anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-03 16:09 +0000
Re: How to use the "compile," word Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-03 22:42 +0200
Re: How to use the "compile," word "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-07-01 04:39 -0400
Re: How to use the "compile," word Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-01 04:03 -0500
Re: How to use the "compile," word Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-01 11:48 +0000
Re: How to use the "compile," word Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-07-02 20:46 -0700
csiph-web