(1) Looks just about right, overall.
(2) I think it would be much better to call the new data structure
ICL object (ICLObj) instead of Prolog object. And of course the
related accessors, etc. would be renamed accordingly.
(3)
> For creation of lists when the length is not known at compile time,
> there will be a function:
>
> PObj *a;
>
> /* Dynamically create a list of N new ints */
> a = malloc(sizeof(*PObj) * n);
> for (i = 0; i < n; i++) {
> a[i] = PRO_NewInt(i);
> }
>
> l = PRO_NewListFromArray(a, n);
Yes, but even here, it appears that the final length has to be known when
the List object is created. What I mean is, there should be constructors/
modifiers for adding elements to an existing List object, and removing
elements, which are efficiently implemented. I'm thinking of a linked
list implementation, as opposed to an array implementation, of the list
elements. (If you covered this somewhere in the message, sorry, I've
just skimmed.)
(4)
> Potential problem: deallocation can get tricky. Since we now permit
> multiple pointers to the same space (instead of creating a new copy
> each time), the programmer has to be extremely careful not to deallocate
> the same space multiple times.
Well, that's just part of working in the C world, not our fault. One very
common technique is to include a ref_count (integer) in the data structure
to help with bookkeeping.
- Dave