🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #38934

Error in PD Modula-2 compiler? Or just in my brain?

#38934
From: Federico Heinz
Date: Fri, 26 May 1989 12:31
66 lines
2263 bytes
  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!/
Technical Details
Message-ID: <340@actisb.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!unido!tub!actisb!federico

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!unido!tub!actisb!federico
From: federico@actisb.UUCP (Federico Heinz)
Newsgroups: comp.sys.atari.st,comp.lang.modula2
Subject: Error in PD Modula-2 compiler? Or just in my brain?
Message-ID: <340@actisb.UUCP>
Date: 26 May 89 12:31:51 GMT
Distribution: comp
Organization: Actis in Berlin GmbH, W. Germany
Lines: 66