Article View: comp.lang.oberon
Article #817Why doesn't Oberon have proper procedure values?
From: Mike Spivey
Date: Mon, 22 Jan 1996 12:57
Date: Mon, 22 Jan 1996 12:57
32 lines
1555 bytes
1555 bytes
Oberon allows procedures to be passed as arguments of other procedures, and to be stored as components of records: in fact, this is the basis of Oberon's use in object-oriented programming. But there seems to be a language restriction that prohibits the use of local procedures in this way -- and it seems to me that this resticts the usefulness of the language in a serious way. For example, we can define collections that support iterator methods, but these methods would be more useful if their arguments could be local procedures. To give a trivial example: PROCEDURE sum(xs: intset); VAR s: integer; PROCEDURE add(x: integer); BEGIN s := s + x END add; BEGIN s := 0; xs.do(add); RETURN s END sum; (sorry about the syntax). This procedure sums a set of integers by calling the iterator 'do', passing a local procedure that adds each number to the local variable 's'. Without local procedures as parameters, 's' would have to be made a global variable -- Yuk! Is there any good reason why Oberon doesn't allow this? I don't seem to have any serious difficulty in implementing it! -- Mike Spivey
Technical Details
Message-ID:
<1996Jan22.125737.5658@zermelo.comlab.ox.ac.uk>Path:
arc1-ca.pugleaf.net!news.ox.ac.uk!mikeShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.ox.ac.uk!mike From: mike@comlab.ox.ac.uk (Mike Spivey) Newsgroups: comp.lang.oberon Subject: Why doesn't Oberon have proper procedure values? Date: Mon, 22 Jan 1996 12:57:37 GMT Organization: Oxford University Computing Laboratory, UK Message-ID: <1996Jan22.125737.5658@zermelo.comlab.ox.ac.uk> NNTP-Posting-Host: zermelo.comlab.ox.ac.uk Originator: mike@zermelo.comlab