First Impressions

Bruno Medeiros brunodomedeiros+spam at com.gmail
Sun Oct 1 12:46:48 PDT 2006


Derek Parnell wrote:
>>  (2) may, but char[] has no use 
>> other than that of being a string, as a char[] is always a string and a 
>> string is always a char[]. So I don't think string fits (2).
>  
> This is a lttle more debatable, but not worth generating hostility. 
> 
> A string of text contains characters whose position in the string is
> significant - there are semantics to be applied to the entire text. It is
> quite possible to conceive of an application in which the characters in the
> char[] array have no importance attached to their relative position within
> the array *where compared to neighboring characters*. The order of
> characters in text is significant but not necessarily so in a arbitary
> character array. 
> 
> Conceptually a string is different from a char[], even though they are
> implemented using the same technology.
> 

Precisely! And even if such conceptual difference didn't exist, or is 
very rare, 'string' is nonetheless more readable than 'char[]', a fact I 
am constantly reminded of when I see 'int main(char[][] args)' instead 
of 'int main(string[] args)', which translates much more quickly into 
the  brain as 'array of strings' than its current counterpart.

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list