string types: const(char)[] and cstring

Sean Kelly sean at f4.ca
Sun Jun 3 09:00:39 PDT 2007


Walter Bright wrote:
> Tom S wrote:
>> Walter Bright wrote:
>>> Derek Parnell wrote:
>>>> What is the syntax for an immutable array of mutable characters?
>>>
>>> There isn't one. Such a construct is appealing in the abstract, but I 
>>> haven't run across a legitimate use for it yet.
>>
>> Are we only talking strings here or general arrays? Because if general 
>> arrays are concerned, I can come up with an example.
> 
> In general.
> 
> 
>> An immutable array of mutable data for... e.g. render to texture in a 
>> software renderer (or creating data for a hw texture, or whatnot) So 
>> you basically pass a texture buffer to a function. You don't want it 
>> to realloc the buffer, just to modify its contents...
>>
>> What am I missing here? ;)
> 
> We can all come up with an example, the more interesting case is is it a 
> compelling example? I'm not seeing that.

Most array algorithms would apply.  But I'm still not sure I see the 
point of having an immutable reference, because it's just passed by 
value anyway.  Who cares if the size of the array is modified within a 
function where it's not passed by reference?  The change is just local 
to the function anyway.


Sean



More information about the Digitalmars-d-announce mailing list