[Oberon] Oberon and closures

Aubrey.McIntosh at Alumni.UTexas.Net Aubrey.McIntosh at Alumni.UTexas.Net
Thu Oct 30 16:02:50 MET 2008


I thing I read that procedure variables are being depreciated because
the literature finds some problem with them.  I forget what the
problem is.  Also, I haven't any clue what a "closure" is other than
this discussion, so I would appreciate any pointer to info that may be
more focused than my own Google search.

Anyway, I tried to modify the example a bit more so that it used type
bound procedures, not procedure variables.  Here is the version for
Component Pascal.


MODULE PrivClosureExample;
(* my oberon is also a little rusty *)

TYPE
 Printer = POINTER TO Closure;

 Closure = RECORD
   n-: INTEGER;
 END;

VAR p, q: Printer;

PROCEDURE (this:Printer) Print, NEW;
END Print;

PROCEDURE CreatePrinter*(i: INTEGER): Printer;
 VAR s: Printer;
 BEGIN
   NEW(s); s.n :=i; RETURN s
 END CreatePrinter;

BEGIN
 p:=CreatePrinter(2);
 q:=CreatePrinter(3);
 p.Print;
 q.Print
END PrivClosureExample.


On Thu, Oct 30, 2008 at 3:25 AM, Jörg Straube <joerg.straube at iaeth.ch> wrote:
>
>>> From Wikipedia we find
>>> As a consequence, closures can be used to hide state,
>>> and thus to implement object-oriented programming
>
> As Oberon is object-oriented, we don't need the concept
> of "closures" to implement OOP.
>
> Joerg
>
>
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>



-- 
-- 
Aubrey McIntosh, Ph.D.
1502 Devon Circle
Austin TX 78723-1814
http://home.grandecom.net/~amcintosh/aubrey/Search/


More information about the Oberon mailing list