Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!cs.utexas.edu!uunet!utcsri!geac!itcyyz!yrloc!rbe
From: rbe@yrloc.ipsa.reuter.COM (Robert Bernecky)
Subject: Re: j 5.1, pc, 386
Message-ID: <1992Sep26.041940.4775@yrloc.ipsa.reuter.COM>
Reply-To: rbe@yrloc.ipsa.reuter.COM (Robert Bernecky)
Organization: Snake Island Research Inc, Toronto
References: <920831.093053.ITA.AGRTQB@IRMFAO01> <1992Sep25.050630.20383@yrloc.ipsa.reuter.COM>
Date: Sat, 26 Sep 92 04:19:40 GMT
Lines: 43

In article <1992Sep25.050630.20383@yrloc.ipsa.reuter.COM> hui@yrloc.ipsa.reuter.COM (Roger Hui) writes:
>Alain Delmotte wrote (1992-08-31 09:38:12):
> 
>> 7!:0 is not *free* workspace size as quadWA but *used now* workspace size
>> which means that using 7!:0 '', entering some function definitions, and using
>> again 7!:0 '' should show an increase in the size returned.
> 
>> I would like to have the same quadWA but I suppose there are very good
>> reasons why it is not implemented. Roger?
> 
>A quad-wa facility is difficult to provide given the way J treats memory.
>J uses malloc/free from the C library.  malloc dynamically allocates memory;
>free releases memory previously allocated using malloc.  J itself does

I think Roger's objections are reasonable, but I, too, belong to the
old school, and crave a quad-wa. Here's a possible way to get there:

a. Introduce a heap manager, and allocate from the heap from a once-
   allocated (via malloc) lump of storage. The heap manager worries about
   silliness like where-does-the-storage-live-really. 

b. Modify J to use macros to perform malloc and free, and redefine them
   to call the heap manager instead. This might result, independently from
   any other changes, in marginally better J performance.

c. Introduce a storage counter which can tell from the heap how much storage
   is really available, and have the quadwa thingy invoke it.

d. If you want to get fancy, make J storage references one-way indirect,
   and then you can (for the cost of slower references a lot of the time)
   perform garbage collection. 

I don't propose to do this in the next few weeks, and I doubt if Roger has
the time to do it either.
Bob



Robert Bernecky      rbe@yrloc.ipsa.reuter.com  bernecky@itrchq.itrc.on.ca 
Snake Island Research Inc  (416) 368-6944   FAX: (416) 360-4694 
18 Fifth Street, Ward's Island
Toronto, Ontario M5J 2B9 
Canada
