![]() | ||
| Home | SwiftX Archive | SwiftForth Archive | |

> -----Original Message-----
> From: swiftx-bounce_at_forth.com [mailto:swiftx-bounce_at_forth.com]On Behalf
> Of Nestor D. Closa
> Sent: Monday, August 23, 2004 11:30 AM
> To: swiftx_at_forth.com
> Subject: [swiftx] Re: Error in CREATE DOES>
>
>
> Sorry Elizabeth, I committed a mistake.
> This is the complete code taken from
> http://forth.sourceforge.net/word/structure/index.html
>
>
> : STRUCTURE ( "name" -- xx offset )
> CREATE
> HERE ( leave the address of the following sizeof-comma )
> 0 DUP , ( initial size is zero and left on the stack )
> DOES> ( has the address of the sizeof-comma )
> CREATE ( make a variable )
> @ ALLOT ( and make the variable that long )
> ;
Yes, your version had the DUP in the wrong place.
> : ENDSTRUCTURE ( xx offset -- )
> SWAP ! ( store the last endoffset into the sizeof-comma )
> ;
>
> : SIZEOF ( "name" -- size )
> ' >BODY @ ( get the sizeof ... some implementations need also >DOES )
> STATE @ IF [COMPILE] LITERAL THEN
> ; IMMEDIATE
>
> : NEWFIELD ( offset field_size "name" -- offset' )
> CREATE
> OVER , ( store the current end_offset )
> + ( increase the end_offset by the field_size )
> DOES>
> @ + ( add the memorized offset of the field)
> ;
It's unclear how this is to be used, though. It seeme unnecessarily complex
to me. I like the Open Firmware version better.
Also, I can't help much with your original complaint of an error message,
since I don't know what it was. I suspect that it was a consequence of
having an extra address on the stack rather than a zero, though, and hence
making a humungous size at some point.
Cheers,
Elizabeth
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
For list command help, send subject "help" to swiftx-request_at_forth.com
Message archives are located at http://www.forth.com/archive/swiftx
----------------------------------------------------------------------
This list is a forum for SwiftX users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Mon Aug 23 2004 - 11:52:13 PDT
This archive was generated by hypermail 2.2.0 : Fri Dec 05 2008 - 03:04:23 PST