🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3343

Re: ****HELP POINTER TO A SET *****

#3343
From: Peter Moylan
Date: Thu, 07 Mar 1996 04:02
48 lines
2164 bytes
Satpal Chander (c9502007@zeus.hud.ac.uk) wrote:

>I need to knoiw how to decode a pointer to a set eg
>set_ptr = pointer to my_set
>my_set = (hello,there,how,are,you)

    TYPE
        MyType = (hello, there, how, are, you);
        SetPtr = POINTER TO MySet;
        MySet = SET OF MyType;

    VAR
        x: MyType;  y: MySet;  p: SetPtr;

    BEGIN
        x := hello;
        y := MySet {there, are};
        NEW (p);
        p^ := MySet {hello, you};
        y := p^;
        p^ := p^ + x;

        (* and so on *)

From some ambiguities in your question, it's not clear whether
you need a point to a set or a pointer to an enumerated type.
Before using any of this, you need to have a clear picture of
which types you really do need.

>How do you exit a program in M2. Imean just exit the program totally
>from anywhere within it???

From vague memory, I think it's the HALT statement.  The reason
my memory of this vague is that, in years of Modula-2 programming,
I've never found any use for this statement.  Giving up a job
in the middle is sloppy programming practice.  You'll get a more
professional-looking result if the program closes down gracefully;
and that includes a provision for anyone reading the code to
be able to see that it's closing down gracefully.  In my opinion,
that means that any procedure that needs to fail should do so
by returning an error code to the caller, rather than simply
collapsing.

--
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
Technical Details
Message-ID: <4hln42$jvg@seagoon.newcastle.edu.au>
Path: arc1-ca.pugleaf.net!fourier.newcastle.edu.au!peter
References: <313DC351.2781E494@zeus.hud.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fourier.newcastle.edu.au!peter
From: peter@fourier.newcastle.edu.au (Peter Moylan)
Newsgroups: comp.lang.modula2
Subject: Re: ****HELP POINTER TO A SET *****
Date: 7 Mar 1996 04:02:10 GMT
Organization: The University of Newcastle
Message-ID: <4hln42$jvg@seagoon.newcastle.edu.au>
References: <313DC351.2781E494@zeus.hud.ac.uk>
Reply-To: peter@tesla.newcastle.edu.au
NNTP-Posting-Host: fourier.newcastle.edu.au
X-Newsreader: TIN [version 1.2 PL2]