[comp.lang.modula2] Compilier Problems

woiccak@acsu.buffalo.edu (thomas s woiccak) (12/02/90)

   I need some help. I've been using the Top-Speed M2 compiler for a few months
now. I've enjoyed every aspect of it except for 2 excluded features. 1 is 
that there is no command line compiler. I really don't like the editor provided
and would love to use my Emacs editor. The other is that all of the compiler 
files and my own files must be in the same BLOODY directory as the compiler.

1) Does anyone know (if possible) how to set the compiler up to look in 
   sub-dirs for stuff?

  Also, I heard that the FST M2 compiler had a command line compiler, SO I got 
that one and installed it. It lets me use my editor and it allows for sub-dirs 
and is very clean and appeared powerful. Of course, that view didn't last.
  My first attempt at compiling a class project crashed on this compiler but
not on Top-Speed's. This is the problem:

e:\m20\mylib>mc project2 /c
Modula-2 compiler, Version 2.0a
(C) Copyright 1987, 1988 Fitted Software Tools. All rights reserved.

Memory model in use: LARGE
Output file format: M2O

Compiling project2.mod (the main module) 
 -> project2.MOD
Pass 1
 -> e:\m20\m2lib\System.DEF
 -> wordlist.DEF, Line    38, Pos    70 -> illegal procedure type


This is the procedure declaration:

DEFINITION MODULE wordlist;

 CONST
   MaxWordLength = 28;                  (* Maximum length of a list word. *)
   MergeCharMax = "~";                  (* Character higher than any word *)
                                        (*  char.                         *)
 TYPE
   List;                                        (* The type of list.      *)
   WordArray = ARRAY[0..MaxWordLength] OF CHAR; (* Word type for each     *)
                                                (*  list element.         *)
   .
   .
   .
 PROCEDURE Contents (CurrentWord : List; OfKey : BOOLEAN) : WordArray;
   .                                                        ^
   .                                                        |
   .                                                       This is where the 
                                                           error points me to.
   This procedure simply returns a string that is held one of 2 fields of 
    the CurrentWord record in a list.

2)WHAT IS THIS COMPILIER TRYING TO TELL ME? 
  
 I  N E E D  to get one of these compiliers to do what I want!
 Can anyone help me with either problem?

If it's easier, E-Mail me at woiccak@acsu.buffalo.edu

Thanks,
TOM WOICCAK
-- 
===============================================================================
Thomas S. Woiccak,  State Univ. of New York at Buffalo, Dept. of Comp. Sci.
   INTERNET: woiccak@acsu.buffalo.edu
   BITNET: woiccak%acsu.buffalo.edu@ubvm.bitnet

gkt@iitmax.IIT.EDU (George Thiruvathukal) (12/03/90)

In article <48608@eerie.acsu.Buffalo.EDU>, woiccak@acsu.buffalo.edu (thomas s woiccak) writes:
>1) Does anyone know (if possible) how to set the compiler up to look in 
>   sub-dirs for stuff?

Depending upon what version of TopSpeed Modula-2 you are using, you can take 
advantage of the "redirection" file.  In version 1, the file was named m2.red;
in version 2, ts.red.

> 
>  Also, I heard that the FST M2 compiler had a command line compiler, SO I got 
>that one and installed it. It lets me use my editor and it allows for sub-dirs 
>and is very clean and appeared powerful. Of course, that view didn't last.

You probably do not want to use the FST M2 compiler, even though it is one of
the better free software packages.  TopSpeed M2 is much better.

TopSpeed has always supplied a command line compiler.  In early versions the
command line compiler was invoked as follows:
   m2 /c filename.mod

Since version 2, the command line compiler has been a separate program from the
TopSpeed multiple language environement.  It is invoked as follows:
   tsc filename.mod

You will have to check out the reference manuals for detailed information on
how the command line compiler and redirection files are used.  There is also
an excellent feature in the TopSpeed compiler which cleanly generalizes the
notion of "project" files.  You can use project files to automate the
compilation and linkage of all possible objects, including EXE, DLL, and LIB
files.

Once you set up your redirection files, I have no doubt that you will be able
to do what you want to do, especially when it comes to "classes," so good luck.


George Thiruvathukal
gkt@iitmax.iit.edu

RW_GRIFFITHS@VAX.ACS.OPEN.AC.UK (12/05/90)

The TopSpeed Modula-2 compiler allows structured types to be returned
as function results. Not all compilers allow this, some only allow
simple types and pointer types to be returned. Maybe the FST compiler
is like that. Try returning a pointer to your WordArray instead.

Rob Griffiths
Computing Department
The Open University.

draper@buster.cps.msu.edu (Patrick J Draper) (12/06/90)

In article <INFO-M2%90120508321696@UCF1VM.BITNET> Modula2 List <INFO-M2%UCF1VM.BITNET@ucf1vm.cc.ucf.edu> writes:
>The TopSpeed Modula-2 compiler allows structured types to be returned
>as function results. Not all compilers allow this, some only allow
>simple types and pointer types to be returned. Maybe the FST compiler
>is like that. Try returning a pointer to your WordArray instead.
>
>Rob Griffiths
>Computing Department
>The Open University.


FST allows complete structures to be returned through a var parameter.
No pointers are necessary for FST.


------------------------------------------------------------------------
Patrick Draper              In times like these it is helpful to
buster.cps.msu.edu          remember that there have always been
                            times like these.
------------------------------------------------------------------------

RW_GRIFFITHS@VAX.ACS.OPEN.AC.UK (12/06/90)

>FST allows complete structures etc.. through var parameters ...

Returning function results through var parameters? A practice somewhat
frowned upon! Write a procedure instead.

Rob Griffiths
Computing Department
The Open University

draper@buster.cps.msu.edu (Patrick J Draper) (12/07/90)

In article <INFO-M2%90120607362197@UCF1VM.BITNET> Modula2 List <INFO-M2%UCF1VM.BITNET@ucf1vm.cc.ucf.edu> writes:
>>FST allows complete structures etc.. through var parameters ...
>
>Returning function results through var parameters? A practice somewhat
>frowned upon! Write a procedure instead.
>
>Rob Griffiths
>Computing Department
>The Open University


Suppose you have a procedure that looks up a record in an index and
returns the record number, a common database procedure. Both the
database and index might have to be changed in the function, and need to
be returned through variable parameters.

example:

PROCEDURE ReturnKeyRecord (VAR db : DB; 
                           VAR index : INDEX;
                           key : ARRAY OF CHAR) : LONGCARD;

This procedure accepts two types that hold all relevant information
about the database and index files, such as record length, field names,
etc. The return value is the record in the database where the key was
found. Both db and index are modified by some aspect of this function
(when the key is found, both the db and index file pointers are changed)
and MUST be returned or the program will crash.

The ability to return values through both the parameter and return value
is a feature of M2 because it is intuitive, and is also a safe
mechanism. The example I have given above is much more logical to me
than the alternative form where a variable called record is a parameter.
When I look at the function, I KNOW that the primary focus of the
function is to return a LONGCARD based on the parameters given.


------------------------------------------------------------------------
Patrick Draper              In times like these it is helpful to
buster.cps.msu.edu          remember that there have always been
                            times like these.
------------------------------------------------------------------------