Article View: comp.lang.modula2
Article #3875Re: procedure variables ...
From: M. Wille
Date: Mon, 05 Oct 1987 07:48
Date: Mon, 05 Oct 1987 07:48
35 lines
1840 bytes
1840 bytes
MSRS002@ECNCDC.BITNET writes
>Modula allows a variable to be a procedure type, and that variable to
>be assigned the "value" of different procedures. This is a very usefull
>thing when making programs such as operating systems or I/O drivers, but
>it leads to one question. Consider the following scrap of code:
PROCEDURE A;
VAR P: PROC;
PROCEDURE B;
VAR X: CARDINAL;
PROCEDURE C;
BEGIN
X := 17
END C;
BEGIN
P := C;
END B;
BEGIN
B; P
END A ;
Do you really think that your code scrap makes any sense. Calling 'C'
outside of its environment does not work in Modula-2. Our compiler
rejects this piece of code, saying that the procedure 'C' in the
assignment 'P := C' is not declared on level 0. Hopefully, other
compilers do the same.
Finally, I will provide you with Wirth's solution of this problem. He
simply restricted the use of assigned procedures to non-local procedures
(see Programming in Modula-2 3rd. Ed., p. 151).
------------------------------------------------------------------
Matthias Wille | CSNET: wille@ifi.ethz.ch
Institut fuer Informatik | wille@komsys.ifi.ethz.ch
ETH - Zentrum | UUCP: ..mcvax!cernvax!ethz!wille
CH-8092 Zuerich Switzerland | Phone: (00411) 256 23 51
Technical Details
Message-ID:
<208@bernina.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!cernvax!ethz!willeShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!cernvax!ethz!wille From: wille@ethz.UUCP (M. Wille) Newsgroups: comp.lang.modula2 Subject: Re: procedure variables ... Message-ID: <208@bernina.UUCP> Date: Mon, 5-Oct-87 03:48:28 EDT Article-I.D.: bernina.208 Posted: Mon Oct 5 03:48:28 1987 Date-Received: Fri, 9-Oct-87 03:19:00 EDT Reply-To: wille@ethz.UUCP (M. Wille) Distribution: world Organization: ETH Zuerich, Switzerland Lines: 35