Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #4589
| From | Julian Fondren <ayrnieu@gmail.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: multi-threading in Forth? |
| Date | 2011-08-04 13:54 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <86d3gl57oi.fsf@gmail.com> (permalink) |
| References | <j1cd95$2md$1@dont-email.me> <07679799958436@frunobulax.edu> <j1dhh8$g8$1@dont-email.me> <bwakg6jwq2jn.oauz4x37l39u.dlg@40tude.net> <j1eev7$n41$1@dont-email.me> |
Mark Wills <markrobertwills@yahoo.co.uk> writes:
> On 04/08/2011 12:42, coos haak wrote:
>> Op Thu, 04 Aug 2011 08:25:27 +0100 schreef Mark Wills:
>>
>>> On 04/08/2011 05:36, Marcel Hendrix wrote:
>>>> To implement this non-standard code, please use this non-standard trick
>>>> (as shown earlier) to prevent in-lining:
>>>>
>>>> : foo r> r> swap>r>r [ -opt ] ;
>>>> : bar 11 . foo 111 . ;
>>>> : baz 22 . bar 222 . ;
>>>>
>>>> FORTH> baz 22 11 222 111 ok
>>>>
>>>> -marcel
>>>>
>>>
>>> What's non-standard about that code?
>>
>> The placement of return addresses on the return stack is not demanded by
>> the current standard. E.g. FigForth and F83 placed them on the return
>> stack, by tradition and simplicity. Currently an implementation may place
>> them anywhere, even not on the return stack.
>> So manipulation of items on the return stack by Foo is allowed, but there
>> is no guarantee that you manipulate return addresses.
>>
>> I too have an implementation where the inlining in FOO (called CO here,
>> courtesy of Albert) must be switched of.
>>
>
> Do you have any idea just how ridiculous that sounds? :-/ I realise
> you are just quoting the standard, but jeesh... "The placement of
> return addresses on the return stack is not demanded by the current
> standard"... FFS... Is it possible to produce a more left-leaning
> woolly standard than the current one? I think not!
There's no need to beat on ANS Forth; it correctly tells you that this
technique will have portability issues. Just deal with them. It's not
like a much-less-followed standard would be free of issues like this.
If you search for "recognizing tail recursion" on Google Groups (still
useful for Usenet, just not for following it), you'll find some
interesting comments about this and the standard's position on it.
So, just declare an environmental dependency on... whatever this is
called, exactly, and use system optimizer hooks on those systems that
are otherwise OK with the practice. You're now aware of the iForth
hook; the SwiftForth hook is NO-TAIL-RECURSION , used like IMMEDIATE
\ : call >r ;
: concat ( c-addr1 u1 c-addr2 u2 -- c-addr3 u1+u2 )
third 2dup + dup >r allocate throw >r
r@ + swap move r@ swap move r> r> ;
: free-after ( a u -- a u )
over r> swap >r ['] call catch r> free throw throw ;
\ Frees after the string is typed
: x s" hi" s" there" concat free-after cr type ;
\ Frees after the string is typed in Z
: y s" hi" s" there" concat free-after ;
: z y cr type ;
If you want the X behavior but not the Z behavior in this instance, use
NO-TAIL-RECURSION on FREE-AFTER and Y will reliably do the wrong thing
of freeing the string before returning it.
From another time that this has been discussed:
http://groups.google.com/group/comp.lang.forth/msg/7e37f3b5f43cddf9
SP> The chances of understanding are much improved by extensive
SP> commenting or documentation in the source code. They are
SP> also improved by suitable choice of word names, even if these
SP> are simply renamings.
SP> In the case of LATER, the assumption that return addresses are
SP> on the return stack was unstated. Michael has proposed using
SP> RA as an indicator for this. It is an unfortunate side-effect
SP> of ANS Forth that such techniques are sometimes disparaged.
SP>
SP> : later \ -- : resume in CALLER'S CALLER
SP> \ Document assumptions here
SP> ra> ra> swap >ra >ra
SP> ;
SP>
SP> Some code just *is* difficult to understand, and Forth seems
SP> to enable use of difficult (rare?) techniques more than most
SP> other languages.
SP>
SP> This particular example should not be discouraged, it should
SP> instead be documented and placed in a system layer rather
SP> than an application layer. I would rather call this word
SP> some thing like
SP> ;LATER:
SP> [LATER]
SP> to indicate that something startling will happen.
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
multi-threading in Forth? Michael L Gassanenko <m_l_g3@yahoo.com> - 2011-08-02 02:01 -0700
Re: multi-threading in Forth? mhx@iae.nl (Marcel Hendrix) - 2011-08-02 11:22 +0200
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-02 15:26 +0200
Re: multi-threading in Forth? mlg3 <m_l_g3@yahoo.com> - 2011-08-04 01:06 +0400
Re: multi-threading in Forth? mhx@iae.nl (Marcel Hendrix) - 2011-08-04 06:36 +0200
Re: multi-threading in Forth? Mark Wills <markrobertwills@yahoo.co.uk> - 2011-08-04 08:25 +0100
Re: multi-threading in Forth? coos haak <chforth@hccnet.nl> - 2011-08-04 13:42 +0200
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-04 14:35 +0200
Re: multi-threading in Forth? Elizabeth D Rather <erather@forth.com> - 2011-08-04 08:30 -0500
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-04 15:38 +0200
Re: multi-threading in Forth? Elizabeth D Rather <erather@forth.com> - 2011-08-04 09:12 -0500
Re: multi-threading in Forth? Mark Wills <markrobertwills@yahoo.co.uk> - 2011-08-04 16:50 +0100
Re: multi-threading in Forth? mlg3 <m_l_g3@yahoo.com> - 2011-08-04 23:52 +0400
Re: multi-threading in Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-05 08:50 -0500
Re: multi-threading in Forth? Mark Wills <markrobertwills@yahoo.co.uk> - 2011-08-04 16:49 +0100
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-04 19:23 +0200
Re: multi-threading in Forth? Elizabeth D Rather <erather@forth.com> - 2011-08-05 10:57 -0500
Re: multi-threading in Forth? stephenXXX@mpeforth.com (Stephen Pelc) - 2011-08-04 14:16 +0000
Re: multi-threading in Forth? Mark Wills <markrobertwills@yahoo.co.uk> - 2011-08-04 16:51 +0100
Re: multi-threading in Forth? stephenXXX@mpeforth.com (Stephen Pelc) - 2011-08-04 17:14 +0000
Re: multi-threading in Forth? "Rod Pemberton" <do_not_have@noavailemail.cmm> - 2011-08-06 03:46 -0400
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-04 19:11 +0200
Re: multi-threading in Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-05 08:43 -0500
Re: multi-threading in Forth? mlg3 <m_l_g3@yahoo.com> - 2011-08-06 01:49 +0400
Re: multi-threading in Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-06 03:13 -0500
Re: multi-threading in Forth? mlg3 <m_l_g3@yahoo.com> - 2011-08-09 04:41 +0400
Re: multi-threading in Forth? mlg3 <m_l_g3@yahoo.com> - 2011-08-09 11:01 +0400
Re: multi-threading in Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-10 09:02 -0500
Re: multi-threading in Forth? mlg3 <m_l_g3@yahoo.com> - 2011-08-11 01:10 +0400
Re: multi-threading in Forth? Ouatu Bogdan <ouatubi@gmail.com> - 2011-08-10 13:22 +0000
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-06 01:12 +0200
Re: multi-threading in Forth? coos haak <chforth@hccnet.nl> - 2011-08-06 02:37 +0200
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-06 12:54 +0200
Re: multi-threading in Forth? alextangent <blog@rivadpm.com> - 2011-08-06 12:15 +0100
Re: multi-threading in Forth? Elizabeth D Rather <erather@forth.com> - 2011-08-05 22:23 -0500
Re: multi-threading in Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-06 03:17 -0500
Re: multi-threading in Forth? Julian Fondren <ayrnieu@gmail.com> - 2011-08-05 19:02 -0500
Re: multi-threading in Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-06 04:01 -0500
return-address manipulation (was: multi-threading in Forth?) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-08-06 16:35 +0000
Re: return-address manipulation Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-08-07 11:45 +0100
Re: return-address manipulation Josh Grams <josh@qualdan.com> - 2011-08-08 09:40 +0000
Re: return-address manipulation Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-08-08 12:17 +0100
Re: return-address manipulation Josh Grams <josh@qualdan.com> - 2011-08-08 12:29 +0000
Re: return-address manipulation mlg3 <m_l_g3@yahoo.com> - 2011-08-09 03:54 +0400
Re: return-address manipulation mlg3 <m_l_g3@yahoo.com> - 2011-08-09 02:52 +0400
Re: return-address manipulation Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-08-09 20:54 +0100
Re: return-address manipulation mlg3 <m_l_g3@yahoo.com> - 2011-08-11 09:00 +0400
Re: return-address manipulation Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-09 14:49 -0500
Re: return-address manipulation anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-08-10 09:03 +0000
Re: return-address manipulation Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-10 05:13 -0500
Re: return-address manipulation mlg3 <m_l_g3@yahoo.com> - 2011-08-11 09:24 +0400
Re: return-address manipulation Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-11 04:09 -0500
Re: return-address manipulation mlg3 <m_l_g3@yahoo.com> - 2011-08-11 09:36 +0400
Re: return-address manipulation mlg3 <m_l_g3@yahoo.com> - 2011-08-11 09:54 +0400
Re: return-address manipulation Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-11 04:16 -0500
Re: multi-threading in Forth? Julian Fondren <ayrnieu@gmail.com> - 2011-08-07 01:43 -0500
Re: multi-threading in Forth? Spam@ControlQ.com - 2011-08-06 12:36 -0400
Re: multi-threading in Forth? Julian Fondren <ayrnieu@gmail.com> - 2011-08-07 01:13 -0500
Re: multi-threading in Forth? mlg3 <m_l_g3@yahoo.com> - 2011-08-09 02:35 +0400
Re: multi-threading in Forth? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-08-07 10:08 +0000
Re: multi-threading in Forth? Josh Grams <josh@qualdan.com> - 2011-08-07 13:45 +0000
Re: multi-threading in Forth? mhx@iae.nl (Marcel Hendrix) - 2011-08-05 17:17 +0200
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-05 19:23 +0200
Re: multi-threading in Forth? Elizabeth D Rather <erather@forth.com> - 2011-08-05 10:53 -0500
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-05 19:18 +0200
Re: multi-threading in Forth? Elizabeth D Rather <erather@forth.com> - 2011-08-06 09:59 -0500
Re: multi-threading in Forth? Spam@ControlQ.com - 2011-08-06 12:28 -0400
Re: multi-threading in Forth? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-08-06 11:29 +0000
Re: multi-threading in Forth? Mark Wills <markrobertwills@yahoo.co.uk> - 2011-08-04 16:47 +0100
Re: multi-threading in Forth? Julian Fondren <ayrnieu@gmail.com> - 2011-08-04 13:54 -0500
Re: multi-threading in Forth? coos haak <chforth@hccnet.nl> - 2011-08-04 22:02 +0200
Re: multi-threading in Forth? Elizabeth D Rather <erather@forth.com> - 2011-08-02 08:23 -0500
Re: multi-threading in Forth? Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2011-08-02 15:30 +0200
Re: multi-threading in Forth? Elizabeth D Rather <erather@forth.com> - 2011-08-02 08:53 -0500
Re: multi-threading in Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-08-03 03:53 -0500
csiph-web