digitalmars.D - Non char[] string inconsistencies.
- Derek Parnell (41/41) Mar 04 2005 This compiles ...
This compiles ...
 void main()
 {
  char[] A;
  char[] B;
  A = "abc";
  B = "def" ~ A ~ "ghi";
 }
But this does not ...
 void main()
 {
  dchar[] A;
  dchar[] B;
  A = "abc";
  B = "def" ~ A ~ "ghi";
 }
Errors are ...
test2.d(7): incompatible types for (("def") ~ (A)): 'char[]' and 'dchar[]'
test2.d(7): Can only concatenate arrays, not (char[] ~ dchar[])
test2.d(7): incompatible types for (("def" ~ A) ~ ("ghi")): 'int' and
char[]'
test2.d(7): Can only concatenate arrays, not (int ~ char[])
test2.d(7): cannot implicitly convert expression "def" ~ A ~ "ghi" of type
int to dchar[]
??? Why is this so ??? I can only assume that bare string literals are
presumed to be char[].
But this *does* compile ...
 void main()
 {
  dchar[] A;
  dchar[] B;
  A = "abc";
  B = "def";
  B ~= A;
  B ~= "ghi";
 }
So bare string literals are not always char[].
-- 
Derek Parnell
Melbourne, Australia
5/03/2005 10:01:05 AM
 Mar 04 2005








 
  
  
  Derek Parnell <derek psych.ward>
 Derek Parnell <derek psych.ward>