Xref: utzoo comp.lang.c:7629 comp.software-eng:260 Path: utzoo!mnetor!uunet!mcvax!enea!sommar From: sommar@enea.se (Erland Sommarskog) Newsgroups: comp.lang.c,comp.software-eng Subject: Re: Writing upgradable data structures Message-ID: <2767@enea.se> Date: 26 Feb 88 10:13:00 GMT References: <2307@geac.UUCP> Reply-To: sommar@enea.UUCP(Erland Sommarskog) Followup-To: comp.software-eng Organization: ENEA DATA AB, Sweden Lines: 28 David Collier-Brown (daveb@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@enea.UUCP "Souvent pour s'amuser les hommes d'equipages and it's like talking to a stranger" -- H&C.