Thread View: comp.lang.modula2
6 messages
6 total messages
Started by J.Last
Mon, 04 Mar 1996 19:20
structured types & procedures
Author: J.Last
Date: Mon, 04 Mar 1996 19:20
Date: Mon, 04 Mar 1996 19:20
4 lines
702 bytes
702 bytes
I use both the FTL Modula-2 compiler for CP/M and the Stony Brook compiler for the PC. In the FTL compiler, this statement was fine: TYPE Vector: ARRAY [0..10] OF REAL;
Re: structured types & procedures
Author: Bill Seurer
Date: Thu, 07 Mar 1996 15:08
Date: Thu, 07 Mar 1996 15:08
15 lines
938 bytes
938 bytes
In article <DnrCDH.17u@lut.ac.uk>, "J.Last" <eljl3@dwalin.lut.ac.uk> writes: |> I use both the FTL Modula-2 compiler for CP/M and the Stony Brook compiler for |> the PC. In the FTL compiler, this statement was fine: |> |> TYPE Vector: ARRAY [0..10] OF REAL; Try TYPE Vector = ARRAY [0..10] OR REAL; The one with the : in it is invalid syntax. -- - Bill Seurer ID Tools and Compiler Development IBM Rochester, MN Business: BillSeurer@vnet.ibm.com Home: BillSeurer@aol.com
Re: structured types & procedures
Author: J.Last
Date: Fri, 15 Mar 1996 14:49
Date: Fri, 15 Mar 1996 14:49
37 lines
2045 bytes
2045 bytes
seurer@nordruth.rchland.ibm.com (Bill Seurer) wrote:
>In article <DnrCDH.17u@lut.ac.uk>, "J.Last" <eljl3@dwalin.lut.ac.uk> writes:
>|> I use both the FTL Modula-2 compiler for CP/M and the Stony Brook compiler for
>|> the PC. In the FTL compiler, this statement was fine:
>|>
>|> TYPE Vector: ARRAY [0..10] OF REAL;
>
>Try
>
> TYPE Vector = ARRAY [0..10] OR REAL;
>
>The one with the : in it is invalid syntax.
>--
>
>- Bill Seurer ID Tools and Compiler Development IBM Rochester, MN
> Business: BillSeurer@vnet.ibm.com Home: BillSeurer@aol.com
Yeah, sorry for this posting. There's a mistake there....full marks you spotted
it. This posting only got half posted for some reason. What I meant to say was:
My FTL M-2 compiler allows me to return structured types like this:
PROCEDURE Thingy(Bob:REAL):StructuredType;
Whereas the StonyBrook DOS compiler won't let me. I have to do:
PROCEDURE Thingy(Bob:REAL;VAR Fred:StructuredType);
Is there a good reason for this?
--
_________ _______________________________ _________
< ""/_\"" \ / \ / ""/_\"" >
< (.o.) \/ Jake Last \/ (.o.) >
< v~v /\ eljl3@gimli.lut.ac.uk /\ v~v >
<_________/ \_______________________________/ \_________>
<http://www.geocities.com/SiliconValley/2915>
Re: structured types & procedures
Author: Peter Moylan
Date: Sun, 17 Mar 1996 22:16
Date: Sun, 17 Mar 1996 22:16
39 lines
2077 bytes
2077 bytes
J.Last (eljl3@dwalin.lut.ac.uk) wrote:
>My FTL M-2 compiler allows me to return structured types like this:
>PROCEDURE Thingy(Bob:REAL):StructuredType;
>Whereas the StonyBrook DOS compiler won't let me. I have to do:
>PROCEDURE Thingy(Bob:REAL;VAR Fred:StructuredType);
>Is there a good reason for this?
The original Modula-2 compilers, as described in "Programming
in Modula-2" by Niklaus Wirth, did not allow structured
types as function return types. This followed a tradition
established in Pascal. Wirth is reported to have said that
this was an implementation restriction rather than a language
rule; nevertheless, the de-facto standard of the time, as
described in PIM3, seemed to suggest that structured types
were not allowed, so that was the rule followed by
compiler-writers who thought they were sticking to the
standard.
In some compilers, the authors decided that this was a
stupid restriction, and introduced functions with structured
return types as a "language extension". In fact, most
M2 compilers I've seen allow this.
Now that we have a proper M2 standard, the situation has
been clarified: structured return types are in the language,
and compilers should support them. The catch, of course, is
that the standard is so new that most compilers haven't
caught up with it.
--
Peter Moylan peter@ee.newcastle.edu.au
http://www.eng.newcastle.edu.au/ee/Moylan.html
OS/2 freeware list at
http://www.eng.newcastle.edu.au/ee/Moylan/os2/os2info.html
structured types & procedures
Author: Mike Watterson
Date: Mon, 18 Mar 1996 15:09
Date: Mon, 18 Mar 1996 15:09
5 lines
854 bytes
854 bytes
If your complier doesn't return a structured type (I too used FTL on CP/M and StonyBrook on MSDOS) rather than a VAR paramenter you can return a pointer. In fact FTL seems to allow OPAQUE structured types too, but SBM2 seems to require that all OPAQUE TYPES are pointers.
Re: structured types & procedures
Author: Joerg Haas
Date: Wed, 27 Mar 1996 13:28
Date: Wed, 27 Mar 1996 13:28
23 lines
1373 bytes
1373 bytes
Jake, >PROCEDURE Thingy(Bob:REAL):StructuredType; > >Whereas the StonyBrook DOS compiler won't let me. I have to do: > >PROCEDURE Thingy(Bob:REAL;VAR Fred:StructuredType); > >Is there a good reason for this? No, there isn't. PIM doesn't support structured types as returnvalues of function procedures. But iso says yes to structured returnvalues. The reason (but not a good ;-)) may be, that StonyBrooks Modula was PIM orientated and isn't up to date or up to iso. Joerg. -- |Joerg Haas |voice:02461-59241 |Microsofts philosophi:| |Wendelinusstr.67|email:j.haas@rurtal.de |If you can't make it| |D-52428 Juelich |www :www.juelich.fh-aachen.de/~snark|good,make it look good|
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads