Writing upgradable data structures

Erland Sommarskog sommar at enea.se
Fri Feb 26 20:13:00 AEST 1988


David Collier-Brown (daveb at geac.UUCP) presents a data structure for date
handling which gets lager and larger as time goes by and then continues
with some disadvantages with the method:
>	4) You CAN'T use a severely type-checked language like
>	   Pascal because it knows that you don't want variable
>	   sized structures. (Its hard in Ada[note 3] too. Source:
>	   Paul Stachour).

Doesn't seem very diffcult doing it in Ada. What about:
    Type Date_type is array(integer range <>) of integer;
    Type Date_pointer is access Date_type;
To begin with you allocate a date with:
    Date_p := new Date_type'(1);
When time is come you get a new date with:
    Date_p := new Date_type'(2);
and so on. I have not included a version field here, since I think we
can trust the attribute 'SIZE of Date_p.all.

Note however that this method, as well in C as in Ada, will eventually
break down. Sooner or later theree will not be memory to store the dates.
And if we assume an infinite memory, there is still a limitation of the
number of elements in the array, at least in Ada. Could this be circum-
vented in C?
-- 
Erland Sommarskog       
ENEA Data, Stockholm        
sommar at enea.UUCP           "Souvent pour s'amuser les hommes d'equipages
                            and it's like talking to a stranger" -- H&C.



More information about the Comp.lang.c mailing list