Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #4554
| From | Julian Fondren <ayrnieu@gmail.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: factoring exercise |
| Date | 2011-08-02 17:25 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <86pqkn5u46.fsf@gmail.com> (permalink) |
| References | <44ea6cbf-3e3a-4a65-beb3-b4b3f70b2f07@fq4g2000vbb.googlegroups.com> <c123e369-af17-490e-84d7-b83631319691@f17g2000prf.googlegroups.com> <j19qk0$d2h$1@dont-email.me> |
mlg3 <m_l_g3@yahoo.com> writes:
> Now I have to apologize: I had a false impression that all people read
> Gforth source with no problems, and I am the only one intolerant to
> dual-xts and Gforth internals. x>cflag and x>iflag are a modified
> copy-paste from the Gforth stuff like:
>
> : name>int ( nt -- xt )
> \G @i{xt} represents the interpretation semantics of the word [...]
> (name>x) (x>int) ;
>
>
> The most confusing thing is interpret/compile-int -- this word is not
> a variable, it is a field ( addr -- addr+off).
>
>>> : x>iflag ( cfa x1 -- xt x2 )
> cfa is called cfa but it may be used as an xt
> x1 is a set of flags
>>>[..]
> ( cfa xt )
>>> over interpret/compile? if drop interpret/compile-int @ -2 else
>
> here interpret/compile? takes cfa and checks if it is a dual-xt word;
> DROP -- we just discard x1, x1 is not used for dual-xt words
>
> And the line:
>
> ( cfa ) interpret-compile-int ( cfa+offset ) @ ( xt-int )
>
> explains why cfa is not called xt: the code field is a struct, and we
> fetch a value from that struct. That value also points to some
> structure, but that structure is irrelevant and we call it xt -- an
> opaque execution token.
Is it safe to fetch from the wrong field? If so,
: (x>flag) ( cfa x1 -- xt-c xt-i x2 )
dup restrict-mask and if drop dup -3 else
over interpret/compile? if drop dup interpret/compile-comp @
swap interpret/compile-int @ -2 else
immediate-mask and if dup -1 else
dup 0 then then then ;
: x>cflag ( cfa x1 -- xt x2 ) (x>flag) nip ;
: x>iflag ( cfa x1 -- xt x2 ) (x>flag) rot drop ;
Maybe the fields are adjacent in gforth, and you can e.g.
if drop interpret/compile-int 2@ ( xt-c xt-i ) -2 else
Maybe you can give (X>FLAG) a nicer name and use it in place of X>CFLAG
and X>IFLAG
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
factoring exercise m_l_g3 <m_l_g3@yahoo.com> - 2011-07-28 12:22 -0700
Re: factoring exercise Hugh Aguilar <hughaguilar96@yahoo.com> - 2011-07-29 16:14 -0700
Re: factoring exercise mlg3 <m_l_g3@yahoo.com> - 2011-08-03 01:36 +0400
Re: factoring exercise Julian Fondren <ayrnieu@gmail.com> - 2011-08-02 17:25 -0500
Re: factoring exercise mlg3 <m_l_g3@yahoo.com> - 2011-08-03 23:19 +0400
Re: factoring exercise Julian Fondren <ayrnieu@gmail.com> - 2011-07-29 23:19 -0700
Re: factoring exercise Julian Fondren <ayrnieu@gmail.com> - 2011-07-30 02:45 -0500
Re: factoring exercise arc <arc@vorsicht-bissig.de> - 2011-08-09 10:47 +0000
Re: factoring exercise "arc@vorsicht-bissig.de" <arc@vorsicht-bissig.de> - 2011-08-07 03:11 -0700
Re: factoring exercise Julian Fondren <ayrnieu@gmail.com> - 2011-08-07 13:53 -0500
Re: factoring exercise Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-07-30 02:14 -0500
Re: factoring exercise Hugh Aguilar <hughaguilar96@yahoo.com> - 2011-08-01 21:03 -0700
csiph-web