Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #32852

Re: Write once C and forth structs

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Write once C and forth structs
Date 2014-08-05 12:33 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2014Aug5.143318@mips.complang.tuwien.ac.at> (permalink)
References (2 earlier) <9358212d-746d-4331-b5e5-ded39e632cd7@googlegroups.com> <95f6c055-6369-456d-9356-e5d44c62e47f@googlegroups.com> <op.xj16l3cy6zenlw@localhost> <obydnThvHNyiKkLOnZ2dnUU7-YWdnZ2d@supernews.com> <lroqq2$cka$1@online.de>

Show all headers | View raw


Bernd Paysan <bernd.paysan@gmx.de> writes:
>Andrew Haley wrote:
>> He's talking about type extension.  Like this in C++:
>> 
>> typedef struct {
>>   int one;
>> } a;
>> 
>> typedef struct : a {
>>   int two;
>> } b;
>> 
>> Here, struct b extends a.
>
>Yes, this sort of stuff is pretty useful, so useful that I added it to the 
>Forth200x structure implementation in Gforth:
>
>: extend-structure ( n "name" -- struct-sys n ) \ Gforth
>    \g extend an existing structure
>    standard:field >r 0 value lastxt >body r> ;
>
>And if you want to start a structure that extends nothing? Of course:
>
>: begin-structure ( "name" -- struct-sys 0 ) \ X:structures
>    0 extend-structure ;

Or instead you could just do it as follows:

0
field: one
constant a

a
field: two
constant b

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2014: http://www.euroforth.org/ef14/

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Write once C and forth structs Hannu Vuolasaho <vuokkosetae@gmail.com> - 2014-08-02 13:25 +0300
  Re: Write once C and forth structs Bernd Paysan <bernd.paysan@gmx.de> - 2014-08-02 13:47 +0200
    Re: Write once C and forth structs Hannu Vuolasaho <vuokkosetae@gmail.com> - 2014-08-02 15:40 +0300
      Re: Write once C and forth structs Bernd Paysan <bernd.paysan@gmx.de> - 2014-08-02 19:08 +0200
    Re: Write once C and forth structs hughaguilar96@yahoo.com - 2014-08-02 20:47 -0700
      Re: Write once C and forth structs hughaguilar96@yahoo.com - 2014-08-03 21:03 -0700
        Re: Write once C and forth structs "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-08-04 04:16 -0400
          Re: Write once C and forth structs Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-08-04 11:39 -0500
            Re: Write once C and forth structs Bernd Paysan <bernd.paysan@gmx.de> - 2014-08-04 22:35 +0200
              Re: Write once C and forth structs anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-08-05 12:33 +0000
                Re: Write once C and forth structs hughaguilar96@yahoo.com - 2014-08-05 20:31 -0700
                Re: Write once C and forth structs Raimond Dragomir <raimond.dragomir@gmail.com> - 2014-08-05 21:45 -0700
                Re: Write once C and forth structs Raimond Dragomir <raimond.dragomir@gmail.com> - 2014-08-05 21:45 -0700
                Re: Write once C and forth structs humptydumpty <ouatubi@gmail.com> - 2014-08-05 23:00 -0700
                Re: Write once C and forth structs "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-08-06 16:38 -0400
                Re: Write once C and forth structs hughaguilar96@yahoo.com - 2014-08-06 17:18 -0700
            Re: Write once C and forth structs "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-08-04 17:43 -0400
            Re: Write once C and forth structs Samuel DEVULDER <samuel-dot-devulder-at-laposte-dot-net> - 2014-08-05 08:26 +0200
              Re: Write once C and forth structs hughaguilar96@yahoo.com - 2014-08-05 20:23 -0700
                Re: Write once C and forth structs Samuel DEVULDER <samuel-dot-devulder-at-laposte-dot-net> - 2014-08-06 08:40 +0200
                Re: Write once C and forth structs hughaguilar96@yahoo.com - 2014-08-06 14:43 -0700
                Re: Write once C and forth structs Gerd Brix <gbrix@gmx.eu> - 2014-08-06 08:54 +0200

csiph-web