home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.modula2
- Path: sparky!uunet!spool.mu.edu!caen!batcomputer!ghost.dsi.unimi.it!univ-lyon1.fr!chx400!bernina!neptune!nugget.inf.ethz.ch!marti
- From: marti@nugget.inf.ethz.ch (Robert Marti)
- Subject: Re: C to Modula2 converter?
- Message-ID: <1993Jan12.144358.18576@neptune.inf.ethz.ch>
- Sender: news@neptune.inf.ethz.ch (Mr News)
- Nntp-Posting-Host: nugget.inf.ethz.ch
- Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
- References: <36762.2B50C7C3@puddle.fidonet.org> <1993Jan11.081026.25261@neptune.inf.ethz.ch> <C0qHLI.F7L@agora.rain.com>
- Date: Tue, 12 Jan 1993 14:43:58 GMT
- Lines: 61
-
- In article <C0qHLI.F7L@agora.rain.com>, robart@agora.rain.com
- (Joe Bob) writes in an ongoing thread with contributions form
- Robert Barton (RB) and myself (RM):
-
- RB >>> A C to Modula-2 converter is not possible, since Modula-2 does
- RB >>> not support set complement, structured constants, or null
- RB >>> procedure variables.
-
- RM >> Not possible is a bit strongly worded, considering that I can think
- RM >> of solutions to all three problems.
-
- JB > The lack of structured constants can be worked around to an extent
- JB > by using variables and a long sequence of assignments. There are
- JB > no substitutes for the other two problems, though.
-
-
- Let's see.
-
-
- Set complement:
-
- The set complement of an expression expr of type
- FooSet = SET OF [lb .. ub]
- is
- {lb .. ub} - expr
- (see sections 5 and 8.2.3 of the report).
-
-
- Null procedure variables:
-
- A "clean" solution would be to generate a
- PROCEDURE NullProcT(p1: T1, ... , pn: Tn): RetT;
- BEGIN
- (* you may need to return something of type RetT here *)
- END NullProcT
- for each
- TYPE ProcT = PROCEDURE (T1, ... , Tn): RetT
- and replace tests
- p = NIL (or p # NIL, respectively their C counterparts)
- for a variable p of type ProcT with tests
- p = NullProcT (or p # NullProcT).
-
- Another possibility is to generate an additional type
- ProcTWithNull = RECORD CASE BOOLEAN OF
- TRUE: proc: ProcT
- | FALSE: adr: SYSTEM.ADDRESS
- END
- for each type ProcT, declare all respective procedure variables p
- to be of type ProcTWithNull (not of type ProcT!), write all calls as
- p.proc(...)
- and write all tests for NULL (or NIL) as
- p.adr = NIL (or p.adr # NIL)
-
- Disclaimer: I haven't tried the latter solution, but I think
- it should work. In any case, it's a hack.
-
- --
- Robert Marti | Phone: +41 1 254 72 60
- Informationssysteme | FAX: +41 1 262 39 73
- ETH-Zentrum | E-Mail: marti@inf.ethz.ch
- CH-8092 Zurich, Switzerland |
-