Changes from Version 1 of OOXL

Show
Ignore:
Author:
trac (IP: 127.0.0.1)
Timestamp:
08/29/2006 10:15:33 PM (4 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OOXL

    v0 v1  
     1Example "class": 
     2 
     3{{{ 
     4module Example; 
     5 
     6thread watcher(self) = 
     7  begin 
     8    lock self.mutex do 
     9      wait self.signal, self.mutex; 
     10      :$Signaled.$ 
     11    end;  
     12  end watcher; 
     13 
     14var 
     15  T: array const := { 
     16    "watcher" := watcher 
     17  }; 
     18 
     19begin 
     20end Example. 
     21}}} 
     22 
     23As XL procedures are procedures __or__ threads, depending on keyword used, so are XL methods. Above example illustrates this. 
     24 
     25Client code for this example: 
     26 
     27{{{ 
     28module Test; 
     29 
     30import 
     31  Example; 
     32 
     33proc Main() = 
     34  var 
     35    e := clone(Example.T); 
     36    i; 
     37  begin 
     38    e.watcher(); 
     39 
     40    for i:=1 to 3 do 
     41      delay(1); 
     42      signal e.signal; 
     43      delay(1); 
     44    end; 
     45  end Main; 
     46 
     47begin 
     48end Test. 
     49}}} 
     50 
     51Inheritance is single, but it will be multiple if rationale found. It is done like this: 
     52 
     53{{{ 
     54module Inherited; 
     55 
     56proc another(self) = 
     57  begin 
     58    :... 
     59  end another; 
     60 
     61var 
     62  T: array const := Example.T + { 
     63    "another" := another 
     64  }; 
     65 
     66begin 
     67end Inherited. 
     68 
     69}}} 
     70 
     71As all of this is prototype based, methods with same name in supertype (Example.T) would not be overriden with above syntax. To override them, one will use: 
     72 
     73{{{ 
     74var 
     75  T: array const := { 
     76    "another" := another 
     77  } + Example.T; 
     78}}} 
     79 
     80Few things are on wish-list for now. First, some syntax sugar for object declarations. Right now, we use ''array const'' to store our prototype in and it works, with it's limitiations. 
     81 
     82Runtime object of another order is needed here, and it is right place to introduce some ''XLClass'' object, to store "class" data into. New object mandates new syntax, maybe one where content is given by XLVarList, like: 
     83 
     84{{{ 
     85module Render; 
     86 
     87class 
     88  T = Render.T { 
     89    id: text; 
     90    attrs: array := {}; 
     91  } methods { 
     92    traverse(); 
     93    print(); 
     94  }; 
     95}}} 
     96 
     97Currently, only type system present in XL runtime is Modula-3 one, used through [source:trunk/m3/xl/src/modules/XLModuleRTI.m3 RTI]. Another type system we evaluate for ''in vivo'' integration is Gtk 2.x [http://developer.gnome.org/doc/API/2.0/gobject/ch02.html The Glib Dynamic Type System].  
     98 
     99Emerging XL type system will mostly be aligned towards Modula-3 system, but Glib's is not to be ignored. It would be a boon to fully integrate emerging XL type system with existing Modula-3 and Glib systems. We can inherit multiple object types, even Modula-3/Glib mix. But, for obvious reasons, only one runtime layout can be used and that only for classes with single inheritance. Currently, with [source:trunk/m3/xl/src/modules/XLModuleRTI.m3 RTI] fully enabling read/write access to Modula-3 objects and plans to dynamically add/remove new object types to Modula-3 runtime, Modula-3 runtime layout is clear choice.