Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!rutgers!ames!sdcsvax!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.lang.forth Subject: Re: Pascal-like records in FORTH Message-ID: <19957@ucbvax.BERKELEY.EDU> Date: Tue, 4-Aug-87 20:03:57 EDT Article-I.D.: ucbvax.19957 Posted: Tue Aug 4 20:03:57 1987 Date-Received: Thu, 6-Aug-87 06:49:32 EDT References: <49@gnome.cs.cmu.edu> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Organization: School of Education, UC-Berkeley Lines: 48 Keywords: records, program example In article <49@gnome.cs.cmu.edu> ns@gnome.cs.cmu.edu (Nicholas Spies) writes: ... >The following enable the definition of "records" in FORTH, which have >two properties; the record name returns the length of the record it >names (in bytes), useful for ALLOT and such; the field words will, when >given the start address of an instantiated record, return the address >of the field relative to that location. ... >RECORD Rectangle > Int: +top > Int: +left > Int: +bottom > Int: +right >END-RECORD ... Note that this record package isn't as good as the one I posted last week. In my package, you would say: 2 MAKEREC: Int: RECORD Int: +top Int: +left Int: +bottom Int: +right ENDRECT: Rect: Then, two declare a rectangle or type rect, you would say: Rect: RectVariable Now here is the critical difference: In my record package, records can be used to define other records in addition to defining variables. You can now also say: RECORD Rect: +bound Int: +color ENDREC: ColoredRec: and you've created a record of type colored rect. If you want the size, you just say SIZEOF< RECT: This works in both interpreter and compiler mode. --- David Phillip Oster --My Good News: "I'm a perfectionist." Arpa: oster@dewey.soe.berkeley.edu --My Bad News: "I don't charge by the hour." Uucp: {seismo,decvax,...}!ucbvax!oster%dewey.soe.berkeley.edu