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


Groups > comp.lang.forth > #11955

Re: Distinguishing DOES>

From JennyB <jennybrien@googlemail.com>
Newsgroups comp.lang.forth
Subject Re: Distinguishing DOES>
Date 2012-05-07 07:24 -0700
Organization http://groups.google.com
Message-ID <5450331.179.1336400648164.JavaMail.geo-discussion-forums@vbtf35> (permalink)
References (1 earlier) <4fa3e44d$0$295$14726298@news.sunsite.dk> <jo1e2q$gd0$1@dont-email.me> <4fa4fe14$0$294$14726298@news.sunsite.dk> <8512970.374.1336227597535.JavaMail.geo-discussion-forums@vbez20> <2012May5.165558@mips.complang.tuwien.ac.at>

Show all headers | View raw


On Saturday, 5 May 2012 15:55:58 UTC+1, Anton Ertl  wrote:

> JennyB <jennybrien@googlemail.com> writes:
> >What started me thinking about this was Gforth's INTERPRET/COMPILE , where =
> >' POSTPONE and friends are then redefined to return the appropriate behavio=
> >ur for interpret/compile words. In that case (where any imaginable word may=
> > be tested) there is no 100% portable solution, because you are limited to =
> >comparing data space and you can conceivably come across a definition with =
> >the same data.
> 
> Are you thinking of implementing INTERPRET/COMPILE: portably.  One way
> to do this would be to record the xts of all words defined with
> INTERPRET/COMPILE:.  ' and POSTPONE then check if the word they are
> dealing with has one of these xts, and if so, do the appropriate
> thing.
> 
> Unfortunatley this hinges on the ability to get the xt of every word
> (which ' is not guaranteed to do) and get a predictable result (which
> FIND is not guaranteed to do), so I don't think one can write a
> program that is clearly standard-compliant to does this.
> 

Yes, I think the best we can do is leave LIKE? as implementation-dependent.

I was thinking of a variant of INTERPRET/COMPILE: that returned the compiling action as two cell, the lower of which is the interpretation xt, which the compilation xt may use or drop. That may seem wasteful in the latter case, but it allows me to find or specify the complete interpretation and compilation behaviour of any word, whether it be default, immediate or other.


   : CLONE  ( xt cxt ++ ) 
     CREATE  2, IMMEDIATE 
       DOES> 2@ STATE @ 0= IF DROP THEN EXECUTE ;

   ' DUP  ' COMPILE, clone URCLONE  
   \ a prototype clone of DUP 
    
   : 'COMP  \ ++ xt cxt  ; compiling behaviour of any word
       FIND ?DUP 0= IF 
       COUNT TYPE [CHAR] ? EMIT ABORT THEN 
         -1 = IF 
         ['] COMPILE, ELSE 
       DUP ['] urclone like? IF 
       >BODY 2@ ELSE 
       ['] EXECUTE THEN ; 

  : '   'COMP DROP ; 
  : ['] ' POSTPONE LITERAL ; IMMEDIATE 

  : POSTPONE 'COMP DUP ['] EXECUTE = IF 
                 DROP ELSE 
                 SWAP POSTPONE LITERAL THEN 
               COMPILE, ; IMMEDIATE 

  : & \ ++ create a clone of the following word in the current wordlist
     >IN @ >R 'COMP   
           R> >IN !  CLONE ; 

  : SYNONYM \ ++ newname oldname
              >IN @ >R BL WORD DROP \ skip newname for now 
             'COMP                  \ compiling behaviour of oldname
                 >IN @ R> SWAP >R >IN ! CLONE  \ using newname
             R> >IN !  ;                       \ and skip oldname

 \ Gforth Style Combined Words 

: ct>xtc ( ct -- cxt ) >R :NONAME POSTPONE DROP R> COMPILE, POSTPONE ; ; 

: INTERPRET/COMPILE: ct>cxt CLONE ; 
 

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


Thread

Distinguishing DOES> JennyB <jennybrien@googlemail.com> - 2012-05-03 08:59 -0700
  Re: Distinguishing DOES> Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-05-03 17:23 -0700
    Re: Distinguishing DOES> Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2012-05-04 10:47 +0100
      Re: Distinguishing DOES> Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-05-04 05:12 -0500
        Re: Distinguishing DOES> anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-05-04 11:33 +0000
          Re: Distinguishing DOES> Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-05-04 08:11 -0500
            Re: Distinguishing DOES> anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-05-04 16:18 +0000
              Re: Distinguishing DOES> Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-05-05 02:02 -0500
                Re: Distinguishing DOES> anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-05-05 14:16 +0000
                Re: Distinguishing DOES> Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-05-06 02:53 -0500
                Re: Distinguishing DOES> anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-05-05 14:25 +0000
                Re: Distinguishing DOES> BruceMcF <agila61@netscape.net> - 2012-05-05 08:07 -0700
                Re: Distinguishing DOES> Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-05-08 06:23 -0700
                Re: Distinguishing DOES> Bernd Paysan <bernd.paysan@gmx.de> - 2012-05-09 00:25 +0200
                Re: Distinguishing DOES> Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-05-09 01:26 -0700
                Re: Distinguishing DOES> Mark Wills <markrobertwills@yahoo.co.uk> - 2012-05-09 03:18 -0700
                Re: Distinguishing DOES> Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-05-09 05:29 -0500
                Re: Distinguishing DOES> "Elizabeth D. Rather" <erather@forth.com> - 2012-05-09 07:11 -1000
                Re: Distinguishing DOES> Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2012-05-09 22:48 +0100
                Re: Distinguishing DOES> Bernd Paysan <bernd.paysan@gmx.de> - 2012-05-09 23:22 +0200
                Re: Distinguishing DOES> Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2012-05-09 23:43 +0100
                Re: Distinguishing DOES> Bernd Paysan <bernd.paysan@gmx.de> - 2012-05-10 00:49 +0200
                Re: Distinguishing DOES> Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2012-05-10 11:33 +0100
                Re: Distinguishing DOES> Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-05-10 10:02 +0000
                Re: Distinguishing DOES> Bernd Paysan <bernd.paysan@gmx.de> - 2012-05-10 15:13 +0200
                Re: Distinguishing DOES> Mark Wills <markrobertwills@yahoo.co.uk> - 2012-05-10 05:07 -0700
                Re: Distinguishing DOES> Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-05-10 22:57 -0700
  Re: Distinguishing DOES> Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-05-04 12:37 +0000
  Re: Distinguishing DOES> Doug Hoffman <glidedog@gmail.com> - 2012-05-04 10:14 -0400
    Re: Distinguishing DOES> humptydumpty <ouatubi@gmail.com> - 2012-05-04 20:27 +0000
      Re: Distinguishing DOES> Doug Hoffman <glidedog@gmail.com> - 2012-05-05 06:16 -0400
        Re: Distinguishing DOES> JennyB <jennybrien@googlemail.com> - 2012-05-05 07:19 -0700
          Re: Distinguishing DOES> anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-05-05 14:55 +0000
            Re: Distinguishing DOES> JennyB <jennybrien@googlemail.com> - 2012-05-07 07:24 -0700
          Re: Distinguishing DOES> Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-05-06 11:04 +0000
          Re: Distinguishing DOES> Doug Hoffman <glidedog@gmail.com> - 2012-05-06 07:47 -0400
        Re: Distinguishing DOES> ward@megawolf.com - 2012-05-08 04:39 -0700
          Re: Distinguishing DOES> Doug Hoffman <glidedog@gmail.com> - 2012-05-08 07:50 -0400
  Re: Distinguishing DOES> Hans Bezemer <the.beez.speaks@gmail.com> - 2012-05-05 14:24 +0200
    Re: Distinguishing DOES> Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-05-06 11:09 +0000

csiph-web