1 May 2010 11:09
Re: dynamic array contents and system.move
> At best, one day we may add GPC-compatible array schema types (see > http://www.gnu-pascal.de/gpc/Schema-Types.html, the part under "As a GNU > Pascal extension, the above can also be written as"). These don't hide > anything. Yes, that looks good as it does not violate the rule that an identifier should mean the same memory address independent from context. >> A simple solution would be to use the address the pointer is pointing >> to (address of first element) for fillchar/move too. > It would break code like this: > type tbytedynarr = array of byte; > var a: array of tbytedynarr; > begin > setlength(a,10); > { initialise all dynamic array elements of a} > ... > { now delete one of these elements } > finalise(a[4]); > { and compact the array } > move(a[3],a[4],(length(a)-3)*sizeof(a[0])); > end. > With your change, move() would operate on the contents of a[3] > tbytedynarr instead of on the contents of "a" itself. Yes, that's a problem because a[0] and a[0]^ are not distinguishable. Although I would have expected that special procedures exist to insert and remove array elements so that there is no need to do such things manually which also requires knowledge of the exact handling of dynamic arrays which is not fully documented so you are never sure.(Continue reading)
RSS Feed