Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #43719 > unrolled thread
| Started by | Aliaksei Chapyzhenka <alex.drom@gmail.com> |
|---|---|
| First post | 2015-11-24 21:18 -0800 |
| Last post | 2015-11-25 21:19 -0800 |
| Articles | 6 on this page of 46 — 11 participants |
Back to article view | Back to comp.lang.forth
POSTPONE behaviour Aliaksei Chapyzhenka <alex.drom@gmail.com> - 2015-11-24 21:18 -0800
Re: POSTPONE behaviour Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-24 22:00 -0800
Re: POSTPONE behaviour Aliaksei Chapyzhenka <alex.drom@gmail.com> - 2015-11-24 22:15 -0800
Re: POSTPONE behaviour Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-24 22:54 -0800
Re: POSTPONE behaviour Aliaksei Chapyzhenka <alex.drom@gmail.com> - 2015-11-24 23:09 -0800
Re: POSTPONE behaviour Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-25 08:15 +0100
Re: POSTPONE behaviour Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-24 23:38 -0800
Re: POSTPONE behaviour Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-25 08:46 +0100
Re: POSTPONE behaviour Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-25 00:04 -0800
Re: POSTPONE behaviour rickman <gnuarm@gmail.com> - 2015-11-25 03:01 -0500
Re: POSTPONE behaviour Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-25 00:09 -0800
Re: POSTPONE behaviour rickman <gnuarm@gmail.com> - 2015-11-25 03:23 -0500
Re: POSTPONE behaviour Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-25 01:09 -0800
Re: POSTPONE behaviour rickman <gnuarm@gmail.com> - 2015-11-25 10:49 -0500
Re: POSTPONE behaviour "Elizabeth D. Rather" <erather@forth.com> - 2015-11-25 09:10 -1000
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-25 09:18 +0000
Re: POSTPONE behaviour Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-25 02:21 -0800
Re: POSTPONE behaviour Mark Wills <markwills1970@gmail.com> - 2015-11-25 02:47 -0800
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-25 13:58 +0000
Re: POSTPONE behaviour Mark Wills <markwills1970@gmail.com> - 2015-11-25 06:35 -0800
Re: POSTPONE behaviour Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-25 18:45 +0100
Re: POSTPONE behaviour Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-11-25 22:11 -0800
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-26 07:42 +0000
Re: POSTPONE behaviour "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-11-26 05:20 -0500
Re: POSTPONE behaviour anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-26 16:50 +0000
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-26 17:59 +0000
Re: POSTPONE behaviour Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-27 19:07 +0100
Re: POSTPONE behaviour anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-28 11:24 +0000
Re: POSTPONE behaviour hughaguilar96@gmail.com - 2015-11-26 12:29 -0800
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-27 09:53 +0000
Re: POSTPONE behaviour hughaguilar96@gmail.com - 2015-11-29 21:48 -0800
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-30 12:18 +0000
Re: POSTPONE behaviour Lars Brinkhoff <lars.spam@nocrew.org> - 2015-11-30 13:41 +0100
Re: POSTPONE behaviour hughaguilar96@gmail.com - 2015-11-30 19:56 -0800
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-12-01 09:59 +0000
Re: POSTPONE behaviour hughaguilar96@gmail.com - 2015-12-01 22:46 -0800
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-12-02 07:50 +0000
Re: POSTPONE behaviour anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-11-25 13:45 +0000
Re: POSTPONE behaviour rickman <gnuarm@gmail.com> - 2015-11-25 10:54 -0500
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-25 07:39 +0000
Re: POSTPONE behaviour Aliaksei Chapyzhenka <alex.drom@gmail.com> - 2015-11-24 23:48 -0800
Re: POSTPONE behaviour Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-11-25 08:03 +0000
Re: POSTPONE behaviour Bernd Paysan <bernd.paysan@gmx.de> - 2015-11-25 18:37 +0100
Re: POSTPONE behaviour "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-11-25 01:27 -0500
Re: POSTPONE behaviour Aliaksei Chapyzhenka <alex.drom@gmail.com> - 2015-11-24 22:51 -0800
Re: POSTPONE behaviour Aliaksei Chapyzhenka <alex.drom@gmail.com> - 2015-11-25 21:19 -0800
Page 3 of 3 — ← Prev page 1 2 [3]
| From | Aliaksei Chapyzhenka <alex.drom@gmail.com> |
|---|---|
| Date | 2015-11-24 23:48 -0800 |
| Message-ID | <afdb9bd1-acb0-4b66-b63a-ae766e121665@googlegroups.com> |
| In reply to | #43735 |
Looks like not much to read, (2 lines) ;)
https://cloud.githubusercontent.com/assets/511872/11388254/092617c4-92e9-11e5-9bfb-9e0c5433f12a.png
On Tuesday, November 24, 2015 at 11:39:37 PM UTC-8, Gerry wrote:
> On 25/11/2015 06:54, Raimond Dragomir wrote:
> >> But failing in this case:
> >> T{ : GT1 123 ; -> }T
> >> T{ : GT4 POSTPONE GT1 ; IMMEDIATE -> }T
> >> T{ : GT5 GT4 ; -> }T
> >> T{ GT5 -> 123 }T
> >
> > Well, think about it: GT4 is immediate. It is executed directly when you
> > define GT5. When executed it will call GT1 which leaves 123 on the data stack.
> >
> > So you already have 123 on the stack after GT5 definition.
> > Also, GT5 body is just a nop, because you compiled nothing (GT4 just
> > executed at compile time).
> > So when you lastly execute GT5 it will leave nothing (but you expect 123)
> >
> > Hope it helps
> >
> No, you're wrong. If you try it in GForth
>
> : GT1 123 ; ok
> : GT4 POSTPONE GT1 ; IMMEDIATE ok
> : GT5 GT4 ; ok
> gt5 . 123 ok
> see gt5
> : GT5
> GT1 ; ok
>
> GT4 compiles GT1 into the definition of GT5
>
> From your other post:
>
> > If the word postponed is not immediate, then postpone is redundant.
> > .... FOO ... and
> > .... POSTPONE FOO ... is the same thing if the FOO is not immediate.
>
> is wrong too, POSTPONE is used for macros e.g.
>
> : RDROP POSTPONE R> POSTPONE DROP ;
> : FOO RDROP ; ok
> see RDROP
> : RDROP [']
> r> >comp ['] drop >comp ; immediate ok
> see FOO
> : FOO
> r> drop ; ok
>
> Read the ANS spec for POSTPONE carefully
>
> --
> Gerry
[toc] | [prev] | [next] | [standalone]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2015-11-25 08:03 +0000 |
| Message-ID | <n33pra$3bn$1@dont-email.me> |
| In reply to | #43736 |
On 25/11/2015 07:48, Aliaksei Chapyzhenka wrote:
> Looks like not much to read, (2 lines) ;)
The important bit is:
"... Append the compilation semantics of name to the current
definition. ..."
It doesn't distinguish between immediate and non-immediate words.
So if you have
: foo postpone drop ; immediate
: bar foo ;
When BAR is being compiled FOO is executed because it is immediate and
it compiles DROP into BAR because BAR is the "current definition".
>
> https://cloud.githubusercontent.com/assets/511872/11388254/092617c4-92e9-11e5-9bfb-9e0c5433f12a.png
>
> On Tuesday, November 24, 2015 at 11:39:37 PM UTC-8, Gerry wrote:
>> On 25/11/2015 06:54, Raimond Dragomir wrote:
>>>> But failing in this case:
>>>> T{ : GT1 123 ; -> }T
>>>> T{ : GT4 POSTPONE GT1 ; IMMEDIATE -> }T
>>>> T{ : GT5 GT4 ; -> }T
>>>> T{ GT5 -> 123 }T
>>>
>>> Well, think about it: GT4 is immediate. It is executed directly when you
>>> define GT5. When executed it will call GT1 which leaves 123 on the data stack.
>>>
>>> So you already have 123 on the stack after GT5 definition.
>>> Also, GT5 body is just a nop, because you compiled nothing (GT4 just
>>> executed at compile time).
>>> So when you lastly execute GT5 it will leave nothing (but you expect 123)
>>>
>>> Hope it helps
>>>
>> No, you're wrong. If you try it in GForth
>>
>> : GT1 123 ; ok
>> : GT4 POSTPONE GT1 ; IMMEDIATE ok
>> : GT5 GT4 ; ok
>> gt5 . 123 ok
>> see gt5
>> : GT5
>> GT1 ; ok
>>
>> GT4 compiles GT1 into the definition of GT5
>>
>> From your other post:
>>
>> > If the word postponed is not immediate, then postpone is redundant.
>> > .... FOO ... and
>> > .... POSTPONE FOO ... is the same thing if the FOO is not immediate.
>>
>> is wrong too, POSTPONE is used for macros e.g.
>>
>> : RDROP POSTPONE R> POSTPONE DROP ;
>> : FOO RDROP ; ok
>> see RDROP
>> : RDROP [']
>> r> >comp ['] drop >comp ; immediate ok
>> see FOO
>> : FOO
>> r> drop ; ok
>>
>> Read the ANS spec for POSTPONE carefully
>>
>> --
>> Gerry
--
Gerry
[toc] | [prev] | [next] | [standalone]
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Date | 2015-11-25 18:37 +0100 |
| Message-ID | <n34rff$uvk$1@dont-email.me> |
| In reply to | #43721 |
Raimond Dragomir wrote: > POSTPONE lets you compile immediate words. Immediate words are executed at > compile time, not compiled. Like the famous IF. IF will be executed at > compile time. Your only chance to compile IF in a definition is to > POSTPONE it. > > If the word postponed is not immediate, then postpone is redundant. > ... FOO ... and > ... POSTPONE FOO ... is the same thing if the FOO is not immediate. Wow, clf is degrading fast. Rod Pemberton posted something factually 100% correct (must be marked in the calendar ;-), and now this. No, that's describing the effect of [COMPILE]. IMHO the easiest way to explain for newbees is the postpone mode with ]] foo bar [[. If you have a word : macro ]] foo bar [[ ; immediate which in standard Forth is written : macro postpone foo postpone bar ; immediate, and you use that macro in another word like : baz macro ; then you can think of inserting the words inside the double brackets or after postpone into baz, as if you wrote : baz foo bar ; That works regardless if foo is immediate or not, so : ?EXIT ]] IF drop EXIT THEN [[ ; immediate works fine. Or with postpone: : ?EXIT postpone IF postpone drop postpone EXIT postpone THEN ; immediate It's just more difficult to read with all the postpone clutter. -- Bernd Paysan "If you want it done right, you have to do it yourself" net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ* http://bernd-paysan.de/
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <boo@fasdfrewar.cdm> |
|---|---|
| Date | 2015-11-25 01:27 -0500 |
| Message-ID | <op.x8m78dimyfako5@localhost> |
| In reply to | #43719 |
On Wed, 25 Nov 2015 00:18:28 -0500, Aliaksei Chapyzhenka <alex.drom@gmail.com> wrote: > I having trouble implementing POSTPONE word. Can someone help > me with simple explanation of how POSTPONE works? See my reply to someone else a few years back: https://groups.google.com/d/msg/comp.lang.forth/RqN6h4qNlPs/RrktBeS62cUJ Also, here are older c.l.f. threads with various implementations: https://groups.google.com/d/msg/comp.lang.forth/nNTw9VjlSGU/Ab0Hvqm3jaUJ https://groups.google.com/d/msg/comp.lang.forth/WfbirdJw1lE/VfaM4lp7y1AJ https://groups.google.com/d/msg/comp.lang.forth/-SwXVMNhxHE/e4gQd634KwgJ Rod Pemberton -- How to kill Facebook. Tell a bunch of fourth graders that only old people use Facebook. Wait eight years.
[toc] | [prev] | [next] | [standalone]
| From | Aliaksei Chapyzhenka <alex.drom@gmail.com> |
|---|---|
| Date | 2015-11-24 22:51 -0800 |
| Message-ID | <58f65b1e-a92a-4e6b-a2ad-274b9db53f53@googlegroups.com> |
| In reply to | #43723 |
Thank you Rod, That sounds like great Thanks-Giving read! --Alexey On Tuesday, November 24, 2015 at 10:27:42 PM UTC-8, Rod Pemberton wrote: > On Wed, 25 Nov 2015 00:18:28 -0500, Aliaksei Chapyzhenka <alex.drom@gmail.com> wrote: > > > I having trouble implementing POSTPONE word. Can someone help > > me with simple explanation of how POSTPONE works? > > See my reply to someone else a few years back: > https://groups.google.com/d/msg/comp.lang.forth/RqN6h4qNlPs/RrktBeS62cUJ > > Also, here are older c.l.f. threads with various implementations: > https://groups.google.com/d/msg/comp.lang.forth/nNTw9VjlSGU/Ab0Hvqm3jaUJ > https://groups.google.com/d/msg/comp.lang.forth/WfbirdJw1lE/VfaM4lp7y1AJ > https://groups.google.com/d/msg/comp.lang.forth/-SwXVMNhxHE/e4gQd634KwgJ > > > Rod Pemberton > > > -- > How to kill Facebook. Tell a bunch of fourth graders that > only old people use Facebook. Wait eight years.
[toc] | [prev] | [next] | [standalone]
| From | Aliaksei Chapyzhenka <alex.drom@gmail.com> |
|---|---|
| Date | 2015-11-25 21:19 -0800 |
| Message-ID | <a31dc552-3825-4524-a89a-886b5ea5cbc3@googlegroups.com> |
| In reply to | #43719 |
Great Thanks to ALL of you! Wow, insightful live discussion and elaborate explanations! I especially love explanations from Gerry, Mark, Anton, Bernd and Elizabeth! You have cracked an ice for me. Now I know how to fix my interpreter!
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | comp.lang.forth
csiph-web