🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #2315

M2 to C translation (was: Garden's Point Modula-2)

#2315
From: Marc Wachowitz
Date: Mon, 10 Jun 1991 09:21
41 lines
2615 bytes
On Sat, 8 Jun 91 13:37:17 GMT Ian Moor said:
>
>In article <1991Jun7.114900.7574@hubcap.clemson.edu> untch@hubcap.clemson.edu
>        (Roland Untch) writes:
>
>  >> There is a problem generating C for things that have no close equivalents,
>  >> such as nested procedures, something like
>  >>     (. . . example deleted . . .)
>  >> cannot easily be mapped to C. Gardens Point seems to produce incorrect C
>  >> for something like this.
Might be that there's a bug in Gard Point M2, but your "problem" can be
solved trivially:
  Emit a declaration (not definition, see below) - i.e. a prototype for
  standard C - of the outer procedure before writing out the code for
  inner procedures. Package all variables of the outer procedure that
  are used by nested procedures in a variable (of an appropriately
  declared struct type) and pass the address of this variable when
  calling nested procedures. Similar for more nesting levels; it's
  the usual implementation technique for nested procedures, except
  that struct type declarations and field selectors are used instead
  of translator-calculated offsets.
>
>   >    Do you know for a fact that Garden's Point Modula-2 produces
>   >incorrect C?
>
>More details: this was the SPARC version of Garden's Point, which
>we had for evaluation from their UK agent  RTA before easter. The C output
>from a program like the example I quoted caused the C compiler  to complain
>about an illegal redeclaration of one the procedures. The procedure was
>called before definition in the C.
The illegal redeclaration might be a bug in GP-M2 or in the C compiler
(some kinds of redeclarations are allowed, otheres are not; some C
compilers have problems here).
There's nothing wrong with calling a procedure before definition, you
only need a declaration (and even this may be left implicit in some
cases). In C terminology, a "declaration" is the interface definition
(prototype in standard C), whereas the "definition" provides the full
code of the function.

Marc Wachowitz
X903@DMAFHT1.BITNET
Technical Details
Message-ID: <INFO-M2%91061003471415@UCF1VM.BITNET>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!cis.ohio-state.edu!ucbvax!DMAFHT1.BITNET!X903
References: <mcsun!ukc!icdoc!iwm@UUNET.UU.NET>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!cis.ohio-state.edu!ucbvax!DMAFHT1.BITNET!X903
From: X903@DMAFHT1.BITNET (Marc Wachowitz)
Newsgroups: comp.lang.modula2
Subject: M2 to C translation (was: Garden's Point Modula-2)
Message-ID: <INFO-M2%91061003471415@UCF1VM.BITNET>
Date: 10 Jun 91 09:21:32 GMT
References: <mcsun!ukc!icdoc!iwm@UUNET.UU.NET>
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: Modula2 List <INFO-M2%UCF1VM.BITNET@ucf1vm.cc.ucf.edu>
Organization: The Internet
Lines: 41