Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #13448
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: How to use the "compile," word |
| Date | 2012-07-02 21:39 +0200 |
| Organization | 1&1 Internet AG |
| Message-ID | <jsstee$c0d$1@online.de> (permalink) |
| References | (1 earlier) <7f1f48a4-8c78-43e1-8c5f-92b185382564@f16g2000yqg.googlegroups.com> <jsq2lo$s0m$1@online.de> <c576a3b2-b02a-4190-a4ef-90744d22fefe@t8g2000yqd.googlegroups.com> <jsqlru$rpp$1@online.de> <2012Jul2.190352@mips.complang.tuwien.ac.at> |
Anton Ertl wrote: > That's a bug. VFX's COMPILE, does the right thing for words with > default compilation semantics and for immediate words (for immediate > words VFX's COMPILE, does not give you the compilation semantics, and > there it behaves as specified by COMPILE,). And how would you describe VFX's behavior of ['] IF COMPILE, ? Hint: It performs the compilation semantics of IF, and IF is not an immediate word. > That's certainly a possibility indicated in the description of FIND. Anton, the standard is *not* a divine text. The specification of FIND comes through observation, not to hint you into guessing what the right implementation probably could be. A FIND is both correct if it does return different xts for different states as well if it returns the same xt for the same name all the time. > So you would ruin "COMPILE,", which has a very clear specification, Clear, but wrong. And it is only wrong in corner-cases. > which has also been reconfirmed by the "deities" you would like to use > to override the specification, in order to avoid an implementation > option in FIND which was explicitly allowed in the description of > FIND? No, FIND is still allowed to give different xts depending on state, I just don't want to force anybody to implement it as such. And I don't want *my* FIND to do that. > While I was looking for an example of COMPILE, usage, I came across > this piece of code from Gray: > > : generate-nt \ -- ) > exec dup @ if > @ compile, > else > postpone literal > postpone @ > postpone execute > endif ; This code is perfectly ok, since the xt you compile can only come from :NONAME, which you would have seen if you would have looked up a little, to the definition above: : code-nt \ -- ) \ generates the code for a rule ) :noname get-body generate postpone ; exec ! ; That's the only place where exec is set. A :noname word has default compilation semantics, so your assumption (lit+execute equals compile,) is correct. The main point is: you can't make assumptions about words with non- default compilation semantics, because the way to implement them is not specified by the standard (and if it was, it would be IMMEDIATE + STATE if the interpretation semantics is different). You can't assume that IF, LEAVE, or EXIT are immediate or not, and you can asume even less about S" and TO. They can be state-smart, they can have two different xts depending on state or they can have a different behavior with COMPILE,. That's reality. The way how COMPILE, was envisioned and how it is actually used IMHO leaves no other choice for an intelligent COMPILE, but to be done the way MPE does - you still need to have an immediate flag in the header (for immediate user words and the few standard words which are expicitly specified as immediate), but for all non-immediate words, COMPILE, does the compilation semantics. If you want another word for that purpose, you break the user-written compiler. I'm not sure how much code you really break. Looking at the COMPILE, places in Gforth, *all* of them are applied to words created fully under the control of the program that does COMPILE, - even in those places where the user-written text interpreter is used (my OOF e.g.). I haven't yet rewritten my BerndOOF port to VFX to use the new intelligent COMPILE, yet, but it probably would be a good idea to do so, to get rid of all the state-smartness stuff. I actually don't think writing your own text interpreter is a good idea to solve problems in Forth where you currently need to do that. Recognizers are a much better way to extend (or redefine) the interpreter - you can plug them in where you want, and they work transparently on all input sources, while leaving the rest of the interpreter as is. And the intelligent COMPILE, system fits much nicer into the way I do my recognizers than Gforth's name tokens. I don't want to stop progress by "academic" concerns for which no real evidence that it is problematic has been found, while the strict interpretation of COMPILE, makes it impossible to use COMPILE, for the purpose it originally was envisioned, which seems to be a much stronger concern for me. Specification bugs are the most expensive bugs (IIRC, this is Brooks), and it is because some people insist in that the specification is always right, no matter how bad the consequences are. The broken part in the standard is the term "execution semantics", which is overused. -- Bernd Paysan "If you want it done right, you have to do it yourself" http://bernd-paysan.de/
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