🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4142

Re: Garbage collection

#4142
From: Snorri Agnarsson
Date: Tue, 29 Mar 1988 12:34
53 lines
2501 bytes
From article <8803231100.AA08757@klaus.olsen.uucp>, by nagler%olsen@unizh.UUCP (Robert Nagler):
>> From Snorri Agnarsson:
>> Not true.  It is not possible in general to "roll-your-own" in a
>> satisfactory manner.  ... abstraction garbage collection is a necessity.
> 
> Somehow, I think you will be difficult to satisfy, but here goes:
> 
> The example of Modula-2 list code you gave seems kind of like Lisp and not M2.
>>        X := CONS(Y,Z);
>>        X := HEAD(Y);
>>        X := TAIL(Y);
> 
> The first question I ask is: what does it do?  Program fragments taken
> out of context are always difficult, but this piece of code is beyond me.

The point I'm trying to make is that I don't want to call anything list
processing that does not allow you to write code such as the above and
not worry about eating memory.  The usual definition of CONS, HEAD and TAIL
is that the following equations apply for all X and Y:

	X=HEAD(CONS(X,Y))
	Y=TAIL(CONS(X,Y))

In a real list processing language you should be able to create values
such as CONS(X,Y) and return them as values from a function, discard the
values if you wish without having to deallocate them explicitly, for example
by using the value temporarily in the middle of an expression.
You will also be able to share parts of lists without having to remember
which parts can safely be deallocated and so on.

> 
>  We have a module called lists.  A typical usage is:
>     Lists.MakeFirstNext( elements );
>     WHILE Lists.Next( elements, element, data ) DO
>         (* Do something with "element" and "data" *)
>     END; (* WHILE *)
> 
> You might want to insert into the list:
>     Lists.Insert( elements, newElement, itsData );
> 
 .... long code for module called lists



You can call this module "Lists" if you wish, you can even call this
list processing if you wish, but *I* would not call this list processing.
It seems to me a better name for this module would be "Table".


-- 
Snorri Agnarsson                  Internet:  snorri@rhi.hi.is
Raunvisindastofnun Haskolans      uucp:      ...!mcvax!hafro!krafla!snorri
Dunhaga 3 107 Reykjavik ICELAND
Technical Details
Message-ID: <169@krafla.rhi.hi.is>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!hafro!krafla!snorri
References: <8803231100.AA08757@klaus.olsen.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!hafro!krafla!snorri
From: snorri@rhi.hi.is (Snorri Agnarsson)
Newsgroups: comp.lang.modula2
Subject: Re: Garbage collection
Message-ID: <169@krafla.rhi.hi.is>
Date: 29 Mar 88 12:34:52 GMT
References: <8803231100.AA08757@klaus.olsen.uucp>
Organization: University of Iceland
Lines: 53