Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #15151
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Implementing ." in forth |
| Date | 2012-08-25 09:05 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2012Aug25.110546@mips.complang.tuwien.ac.at> (permalink) |
| References | <k15dp4$kag$1@dont-email.me> <2012Aug23.164507@mips.complang.tuwien.ac.at> <k17ojv$6ei$1@dont-email.me> <2012Aug24.164144@mips.complang.tuwien.ac.at> <k19hgk$qp7$1@dont-email.me> |
Arnold Doray <invalid@invalid.com> writes:
>On Fri, 24 Aug 2012 14:41:44 +0000, Anton Ertl wrote:
>
>>>
>>>: [."] [char] " parse ` sliteral ` type ; immediate
>>>: (.") [char] " parse type ;
>>>
>>
>> Well, a slight variation of that would work when text-interpreted, but
>> not always when ticked or POSTPONEd:
>>
>> : ." state @ if postpone [."] else postpone (.") then ; immediate
>>
>> That's one of the infamous STATE-smart words.
>>
>>
>> You could fix the problem of the STATE-smart version as follows:
>>
>> : '
>> ' dup ['] ." = if drop ['] (.") then ;
>>
>> : ['] ' postpone literal ; immediate
>>
>> : postpone
>> >in @ ['] ' catch if >in ! postpone postpone exit then
>> ['] ." = if drop postpone [."] else >in ! postpone postpone then
>> ; immediate
>>
>
>To paraphrase your code:
>
>a) TICK switches the xt of ." for the xt of (.")
>b) COMPILE-TICK does the same, using the xt of (.")
>c) POSTPONE instead uses the xt of [."]
>
>I'm guessing the change to TICK is really to give the same result as
>the new COMPILE-TICK, eg:
>
>: test ['] ." ;
>test ' ." = . -1 ok
No, the redefinition of ' and ['] is there to let these words produce
an xt for the interpretation semantics. While the standard does not
define interpretation semantics and therefore does not define what ' ."
should do, it's a good idea to make it behave as described above for
consistency with ' S".
>There are only 2 things to do with an XT -- comparison and execution.
>Comparison is covered, since TICK is the only other word that can give an
>XT. So that leaves execution. But when the XT of ." is executed, should
>it not just do the right thing since it is "state smart"?
STATE-smart words generally don't do the right thing when ticked and
executed (see <http://www.taygeta.com/forth/a0007.htm>).
>Here are some tests I ran:
>
>: ` postpone postpone ; immediate
>: [.""] [char] " parse ` sliteral ` type ; immediate
>: (."") [char] " parse type ;
>: ."" state @ if ` [.""] else (."") then ; immediate
>
>\ TICK and COMPILE-TICK have NOT been amended
>
>\ Comparison test
>: test ['] ."" ;
>
>test ' ."" = . -1 ok
>
>\ Execution tests
>: test2 ['] ."" execute ;
>
>test2 Hello World" Hello World ok
>
>: test3 ['] ."" ;
>
>test3 execute Hello World" Hello World ok
>
>' ."" execute Hello World" Hello World ok
>
>
>So my question is in what cases do the amendations to TICK, COMPILE-TICK
>and POSTPONE become necessary?
: ]execute[ ] execute postpone [ ;
' ."" ]execute[ Hello World"
test ]execute[ Hello World"
: test4 postpone ." ;
: test5 [ test4 hello world" ] ; immediate
- 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
Implementing ." in forth Arnold Doray <invalid@invalid.com> - 2012-08-23 14:12 +0000
Re: Implementing ." in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-23 14:45 +0000
Re: Implementing ." in forth Arnold Doray <invalid@invalid.com> - 2012-08-24 11:30 +0000
Re: Implementing ." in forth Josh Grams <josh@qualdan.com> - 2012-08-24 12:56 +0000
Re: Implementing ." in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-24 14:41 +0000
Re: Implementing ." in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-24 16:45 +0000
Re: Implementing ." in forth Arnold Doray <invalid@invalid.com> - 2012-08-25 03:41 +0000
Re: Implementing ." in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-25 09:05 +0000
Re: Implementing ." in forth Arnold Doray <invalid@invalid.com> - 2012-08-29 15:48 +0000
Re: Implementing ." in forth Coos Haak <chforth@hccnet.nl> - 2012-08-29 21:19 +0200
Re: Implementing ." in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-30 13:00 +0000
Re: Implementing ." in forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-08-23 12:00 -0500
Re: Implementing ." in forth Spam@ControlQ.com - 2012-08-23 14:16 -0400
Re: Implementing ." in forth Mark Wills <markrobertwills@yahoo.co.uk> - 2012-08-23 14:37 -0700
Re: Implementing ." in forth "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-08-23 19:37 -0400
Re: Implementing ." in forth hughaguilar96@yahoo.com - 2012-08-24 00:06 -0700
Re: Implementing ." in forth Arnold Doray <invalid@invalid.com> - 2012-08-24 11:32 +0000
Re: Implementing ." in forth Doug Hoffman <glidedog@gmail.com> - 2012-08-24 08:33 -0400
Re: Implementing ." in forth jim@rainbarrel.com - 2012-08-24 09:15 -0700
Re: Implementing ." in forth Chris Hinsley <chris.hinsley@gmail.com> - 2012-08-25 15:15 +0100
csiph-web