To Walter, about char[] initialization by FF
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Mon Jul 31 05:01:24 PDT 2006
Serg Kovrov wrote:
> * Frits van Bommel:
>> Serg Kovrov wrote:
>>> * Oskar Linde:
>>>> Counting the number of characters is also a rather expensive
>>>> operation.
>>>
>>> Indeed. Store once as property (and update as needed) is better than
>>> calculate it each time you need it.
>>
>> Store where? You can't put it in the array data itself without
>> breaking slicing, and you putting it in the reference introduces
>> problems with it getting out of date if the array is modified through
>> another reference (without enforcing COW, that is).
>
> Need to say that I no not have an idea where to store it, neither where
> current length property stored. I'm really glad that compiler do it for me.
>
> As language user I just want to be confident that compiler do it wisely,
> and focus on my domain problems.
The length is stored in the reference, but the character count would not
only depend on the memory location and size (which the reference holds)
but also the data it holds (at least for char and wchar) which may be
accessed through different references as well. That's the problem I was
pointing out.
More information about the Digitalmars-d
mailing list