[Oberon] How to mimic an associative array

Douglas G. Danforth danforth at greenwoodfarm.com
Fri Dec 3 22:38:03 CET 2010

On 12/3/2010 9:23 AM, Duke Normandin wrote:
>   However CGILib would not know in advance
> what data-type was being passed to it. It has to be able to behave
> like a dynamically typed language/module. Is that possible in
> Oberon-2? or with the code that you were so kind to put together?


Yes it is possible to define abstract objects whose type at runtime
can be determined and acted upon accordingly.  Here is an

     Object = POINTER TO RECORD END;    (* Abstract object *)
     O1 = POINTER TO RECORD(Object) .... END; (* concrete object *)
     O2 = POINTER TO RECORD(Object)....END; (* concrete object *)
     On = POINTER TO RECORD(Object)....END; (* concrete object *)

     PROCEDURE Proc (o: Object);
         IF o IS O1 THEN
         ELSIF o IS O2 THEN
         ELSIF o IS On THEN

(PS: you can also use the  operator WITH which casts the object o into 
specific types)


More information about the Oberon mailing list