Calculating the size of colon-sys

Marcos Cruz <[email protected]>
Newsgroups gmane.comp.lang.forth.gforth
Message-ID <20170819193626.GC14260@raspesis>
One subtle problem I had after migrating from Gforth 0.7.3 to 0.7.9 was
some pieces of code broke because they depended on the size of a
_colon-sys_. For, example:

----
: (apart-colon-sys) ( x1 x2 colon-sys -- x1 colon-sys x2 )
                    ( x1 colon-sys x2 -- colon-sys x2 x1 )
  [ /colon-sys 2 + ] literal roll ;

: apart-colon-sys ( a xt colon-sys -- colon-sys a xt )
  (apart-colon-sys) (apart-colon-sys) ;

: :init ( a -- )
  :noname apart-colon-sys (:init)  postpone [:init] ;
  \ Start a definition that will initialize entity _a_ to its default
  \ data.  The definition is finished by `;`.
  \
  \ XXX TODO -- Rewrite, simplify: don't depend on _colon-sys_.
----

Besides, the code assumes the control-flow stack is implemented using
the data stack. This assumption and moving the parameters around
_colon-sys_ were temporary solutions just to make the code work.

So far I had defined a `/colon-sys` constant, kind of naive.  When I
realized the problem was the size of a _colon-sys_ had changed 
in Gforth 0.7.9, I calculated it this way in my personal library:

----
depth value /colon-sys ( -- n )
  \ _n_ is the size of _colon-sys_ in cells.

:noname [ depth /colon-sys - 1- to /colon-sys ] ; drop
  \ Calculate `/colon-sys`.
----

It seems to work fine in all cases.

Anyway, I've searched the sources, but found no method to get the size
of _colon-sys_. Is there any way to get it, already provided by Gforth?

-- 
Marcos Cruz
http://programandala.net
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.