On Friday 16 September 2005 17:34, Sergey Plis wrote:
> Hi!
>
> I noticed the following unexpected behaviour of structure definition.
> When you do
>
> also float
> order
> struct{ cell test } test1
> order
>
> You see that the top dictionary has been replaced after the structure
> was defined with FORTH. That happens all the time.
>
> Is it possible to not alter the dictionary order at structure
> definition? That would seem as a good behaviour.
Yes, fully agreed. Try this patch:
--- struct.fs 28 Dec 2002 17:07:33 -0000 1.1
+++ struct.fs 17 Sep 2005 12:20:11 -0000
@@ -26,7 +26,7 @@
: { ( len -- len len len ) dup dup 1 #struct +! ; immediate
: | ( len +len actlen -- len maxlen len ) max over ; immediate
: } #struct @ IF -1 #struct +! max nip EXIT THEN
- current @ toss definitions
+ current @ toss definitions toss
Create immediate swap , A, compile [
DOES> cell+ @ also context ! name parser toss ; immediate
@@ -38,7 +38,7 @@
>in @ name w@ $5C01 = IF drop + ELSE >in ! .struct' THEN
[ lastcfa @ ] ALiteral IS parser ;
: struct{ ( -- )
- current @ context ! align here 0 voc, current !
+ also current @ context ! align here 0 voc, current !
also (struct #struct off 0 ['] struct-parse IS parser ;
1 constant byte
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/
pgpK5IVao9Spv.pgp
Description: PGP signature
