slang-users mailing list

[2001 Date Index] [2001 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: Object-oriented


Richard van Zon <rvanzon@xxxxxxxxxxxx> wrote:
>Well...I am looking for a matter to divide things like OOP...
>for example...
>
>TBook Book;
>Book.Open();
>Book.Read()
>Book.Page=10;
>Book.Page++;

You can do this:

   static define tbook_open () {...};
   static define tbook_read () {...};

   public define new_tbook ()
   {
      variable t = struct { open, read, page };
      t.open = &tbook_open;
      t.read = &tbook_read;
      t.page = 0;
      
      return t;
   }
   
   variable Book = new_tbook ();
   @Book.read ();
   Book.page++;

--John


[2001 date index] [2001 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]