Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Julian Fondren Newsgroups: comp.lang.forth Subject: Re: factoring exercise Date: Tue, 02 Aug 2011 17:25:13 -0500 Organization: A noiseless patient Spider Lines: 51 Message-ID: <86pqkn5u46.fsf@gmail.com> References: <44ea6cbf-3e3a-4a65-beb3-b4b3f70b2f07@fq4g2000vbb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="cO8zBIpB9LiP7q+vFZIJrA"; logging-data="32723"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19h5R3FwOrsCceL+IUUPQrlKjQLre2ZfXU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) Cancel-Lock: sha1:D/wNeuYm5QjwPH3WR8buwlF1lc0= sha1:p22578y4ejCtQ+iQ4tGB6eDjC88= Xref: x330-a1.tempe.blueboxinc.net comp.lang.forth:4554 mlg3 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