[Oberon] How to mimic an associative array
Duke Normandin
dukeofperl at ml1.net
Fri Dec 3 23:02:53 CET 2010
On Fri, 3 Dec 2010, Douglas G. Danforth wrote:
> 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?
>
> Duke,
>
> Yes it is possible to define abstract objects whose type at runtime
> can be determined and acted upon accordingly. Here is an
> example.
>
> TYPE
> 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);
> BEGIN
> IF o IS O1 THEN
> ...
> ELSIF o IS O2 THEN
> ....
> ELSIF o IS On THEN
> ...
> ELSE
> ...
> END
>
> (PS: you can also use the operator WITH which casts the object o into
> specific types)
It appears that _all_ the horsepower is available in Oberon-2 for me
to do this project and many others. This CGI module project may be a
bit premature for me. I'll continue on with Nikitin's book, and get
_real_ comfortable doing linked lists and doubles, arrays, records and
pointers using Oberon-2. :) When I can walk the Oberon talk, without
falling on my face, then I'll tackle the CGI thing. I've got one done
in C that I can get ideas from as well. Much obliged!
--
Duke
More information about the Oberon
mailing list