[comp.sys.atari.st] Error in PD Modula-2 compiler? Or just in my brain?

federico@actisb.UUCP (Federico Heinz) (05/26/89)

  Yesterday I was attempting to solve a quite nonsensical university
excercise using the recently-posted PD Modula compiler for the ATARI ST,
and I ran into the following problem:

  I was trying to define a stack handling module, basing it on a
sigle-linked list handling module.  Thus I had

    DEFINITION MODULE Lists;

    TYPE
      List;

    (...)

    PROCEDURE CreateList(VAR newList: List);

    (...)

    END Lists;




    IMPLEMENTATION MODULE Stacks;

    TYPE
      Stack = List;

    (...)

    PROCEDURE CreateStack(VAR newStack: Stack);

    VAR
      list: List;

    BEGIN
      CreateList(list);    (* VAR parameters must be of IDENTICAL types *)
      newStack := list;    (* this needs only assignment compatibility  *)
    END CreateStack;

    (...)

    END Stacks;


  To my surprise, the compiler flagged an 'illegal assignment' on the
line 'newStack := list'.  I changed it to 'newStack := Stack(list)',
and the error changed to 'illegal procedure return value' (or something
quite like that).  I checked it with "Programming in Modula-2, 3rd.
Edition", and all I could read out of it was that the original line was
OK, because Stack was declared to be the same as List, and is thus
assignment compatible.  I'm not sure whether the expression 'Stack(list)'
is legal, since there is no explicit mention of type transfer functions
for user-defined types in the book, but I think it is reasonable.

  I can't quite accept that this is a compiler error, since they MUST
have used this sort of capability to port the compiler, so it must be
something I'm doing wrong. Any suggestions?  Thanks in advance


-- 
		Federico Heinz     "I can resist anything but temptation"
                                        -- Oscar Wilde
 From Europe:   ...!mcvax!unido!tub!actisb!federico
 From elsewhere: ...!uunet!pyramid!/

kloppen@gmdzi.UUCP (Jelske Kloppenburg) (05/27/89)

The type transfer in the TU Muenchen Modula2 is as follows:

FROM SYSTEM IMPORT VAL;

VAR b: BITSET;
    c: CARDINAL;

BEGIN ...  c:=VAL(CARDINAL,b); ....

I learned it from reading some source in the package.

      Kloppenburg@kmx.gmd.dbp.de
UUCP: kloppen@gmdzi
                     In real life: Jelske Kloppenburg

kloppen@gmdzi.UUCP (Jelske Kloppenburg) (05/27/89)

In article <340@actisb.UUCP>, federico@actisb.UUCP (Federico Heinz) writes:
> 
>   Yesterday I was attempting to solve a quite nonsensical university
> excercise using the recently-posted PD Modula compiler for the ATARI ST,
> and I ran into the following problem:
> 
>   I was trying to define a stack handling module, basing it on a
> sigle-linked list handling module.  Thus I had
> 
>     DEFINITION MODULE Lists;
> 
>     TYPE
>       List;
> 
>     (...)
> 
>     PROCEDURE CreateList(VAR newList: List);
> 
>     (...)
> 
>     END Lists;
> 
> 
> 
> 
>     IMPLEMENTATION MODULE Stacks;
> 
>     TYPE
>       Stack = List;
> 
>     (...)
> 
>     PROCEDURE CreateStack(VAR newStack: Stack);
> 
>     VAR
>       list: List;
> 
>     BEGIN
>       CreateList(list);    (* VAR parameters must be of IDENTICAL types *)
>       newStack := list;    (* this needs only assignment compatibility  *)
>     END CreateStack;
> 
>     (...)
> 
>     END Stacks;
> 
> 
>   To my surprise, the compiler flagged an 'illegal assignment' on the
> line 'newStack := list'. ...
> ...
> ... Any suggestions?  Thanks in advance
> 

From your example I made 3 files:

1st File:

    DEFINITION MODULE Lists;

    TYPE
      List;

    PROCEDURE CreateList(VAR newList: List);

    END Lists.

2nd File:

    DEFINITION MODULE Stacks;
    FROM Lists IMPORT List;

    TYPE Stack = List;

    PROCEDURE CreateStack(VAR newStack: Stack);

    END Stacks.

3rd File:

    IMPLEMENTATION MODULE Stacks;
    FROM Lists IMPORT CreateList, List;

    PROCEDURE CreateStack(VAR newStack: Stack);

    VAR
      list: List;

    BEGIN
      CreateList(list);    (* VAR parameters must be of IDENTICAL types *)
      newStack := list;    (* this needs only assignment compatibility  *)
    END CreateStack;

    END Stacks.

I compiled these files whith the TU Muenchen Modula2 and no errors were
reported. There may be another cause for your error.

      Kloppenburg@kmx.gmd.dbp.de
UUCP: kloppen@gmdzi

                     In real life: Jelske Kloppenburg

iwm@ic.ac.uk (Ian Moor) (06/14/89)

In article <340@actisb.UUCP> federico@actisb.UUCP (Federico Heinz) writes:

    using the recently-posted PD Modula compiler for the ATARI ST,

I don't normally read the Atari.st groups, but I would indeed like a PD
Modula compiler generating 68K code (for an Amiga). I can't find 
the compiler mentioned on our News server or the UK Lancaster pdsoft
archive (except an IBMPC version without source). So does anybody
know how to obtain the source of a PD Modula-> 68K compiler. I can
bootstrap it using a compiler at here college if need be.

NB Like most europeans, I cannot FTP from the states.

aplusl@ethz.UUCP (Albert Meier) (06/19/89)

There exists a PD Modula-2 compiler that directly produces executables
on Amiga. You may find it on Fish-Disk 113.

    .....           Albert Meier        Tel.  +41/1/700 30 37
   .. ....          A+L AG, Im Spaeten 23, CH-8906 Bonstetten
  ..   ....
 .......A+L.        E-Mail          aplusl@ifi.ethz.(ch/UUCP)
..       .......                 ...mcvax!cernvax!ethz!aplusl