Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #21211

Re: Is there a way to define this portably in ANS Forth?

From Andrew Haley <andrew29@littlepinkcloud.invalid>
Subject Re: Is there a way to define this portably in ANS Forth?
Newsgroups comp.lang.forth
References <0770e496-c689-4cc2-8604-51b9587c187b@googlegroups.com> <KdydnbP57MRR-tHMnZ2dnUVZ_h2dnZ2d@supernews.com> <f3aa84e4-492a-4bd6-b4d6-e21ff6fb8b45@w2g2000pbw.googlegroups.com> <6uqdnSBLArIzlMnMnZ2dnUVZ_gWdnZ2d@supernews.com> <kj1nso$eh5$1@dont-email.me>
Message-ID <pbGdney7Q_lLLsnMnZ2dnUVZ8gCdnZ2d@supernews.com> (permalink)
Date 2013-03-28 16:19 -0500

Show all headers | View raw


Gerry Jackson <gerry@jackson9000.fsnet.co.uk> wrote:
> On 28/03/2013 09:13, Andrew Haley wrote:
>> Hugh Aguilar <hughaguilar96@yahoo.com> wrote:
>>> On Mar 22, 7:16?am, Andrew Haley <andre...@littlepinkcloud.invalid>
>>> wrote:
>>>> The Beez <the.beez.spe...@gmail.com> wrote:
>>>>> A word which creates a named execution token that throws itself on
>>>>> the stack when executed, as if it were defined like this:
>>>>
>>>>> :noname + ; constant plus
>>>>
>>>>> <word> plus + ;
>>>>
>>>>> Just wondering. I'm not getting the right ideas right now :-(
>>>>
>>>> variable poo
>>>>
>>>> : ;   postpone ;
>>>>      poo @ if  poo @ !  0 poo !  then ;  immediate
>>>>
>>>> : bleep   create  here poo !  0 ,  does> @ ;
>>>>
>>>> : <word>   bleep :noname ;
>>>>
>>>> <word> plus + ;
>>>>
>>>> 1 2 plus execute  ok
>>>> . 3  ok
>>>
>>> This assumes that HERE provides what will be the xt of the next colon
>>> word compiled.
>>
>> It does no such thing.  Read it again.
>>
>>> That may be true in some Forths, but it is definitely
>>> "unlawful carnal knowledge." We don't even define what the xt
>>> (execution token) is --- it is not necessarily the cfa, as was true in
>>> Forth-83. Some Forths have the headers in front of the code, and some
>>> have them separate. On modern processors, you generally want them
>>> separate --- this way your code is all adjacent and there will be less
>>> cache-thrashing.
>>>
>>> I still say there is no way to solve this problem in ANS-Forth.
>>
>> If this doesn't work on an ANS Forth system, that system is broken.
> 
> Not necessarily. It only works if poo is initialised to 0 by the Forth 
> system when defined which isn't in the ANS standard. The new definition 
> of ; is executed at the end of bleep when poo has never been written to 
> and may contain some invalid address.

Bah.

variable poo   0 poo !

: ;   postpone ;
     poo @ if  poo @ !  0 poo !  then ;  immediate

: bleep   create  here poo !  0 ,  does> @ ;

: <word>   bleep :noname ;

<word> plus + ;

1 2 plus execute  ok
. 3  ok

Okay, now it's standard.

Andrew.

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Is there a way to define this portably in ANS Forth? The Beez <the.beez.speaks@gmail.com> - 2013-03-22 05:34 -0700
  Re: Is there a way to define this portably in ANS Forth? Mark Wills <markrobertwills@yahoo.co.uk> - 2013-03-22 06:12 -0700
    Re: Is there a way to define this portably in ANS Forth? Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-22 15:59 +0100
      Re: Is there a way to define this portably in ANS Forth? Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-03-22 21:53 -0700
        Re: Is there a way to define this portably in ANS Forth? "Rod Pemberton" <do_not_have@notemailnotq.cpm> - 2013-03-23 02:35 -0400
          Re: Is there a way to define this portably in ANS Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-23 05:37 -0500
        Re: Is there a way to define this portably in ANS Forth? The Beez <the.beez.speaks@gmail.com> - 2013-03-23 04:08 -0700
  Re: Is there a way to define this portably in ANS Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-22 09:16 -0500
    Re: Is there a way to define this portably in ANS Forth? Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-03-27 18:50 -0700
      Re: Is there a way to define this portably in ANS Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-28 04:13 -0500
        Re: Is there a way to define this portably in ANS Forth? Alex McDonald <blog@rivadpm.com> - 2013-03-28 06:54 -0700
        Re: Is there a way to define this portably in ANS Forth? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-03-28 15:36 +0000
          Re: Is there a way to define this portably in ANS Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-28 16:19 -0500
        Re: Is there a way to define this portably in ANS Forth? Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-03-28 20:49 -0700
          Re: Is there a way to define this portably in ANS Forth? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-29 04:25 -0500
  Re: Is there a way to define this portably in ANS Forth? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-03-22 14:41 +0000

csiph-web