[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gforth] Calculating the size of colon-sys
From: |
Marcos Cruz |
Subject: |
[gforth] Calculating the size of colon-sys |
Date: |
Sat, 19 Aug 2017 21:36:26 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gforth] Calculating the size of colon-sys,
Marcos Cruz <=