String convention

Don Clugston dac at nospam.com.au
Mon Jul 3 02:34:31 PDT 2006


Niklas Ulvinge wrote:
> Thanks for all replies, now I understand most of what I wanted to know.
> (although the Q about the internal structure of dynamic arrays still remains...)
> 
> 
> In article <op.tb03wsb06b8z09 at ginger.vic.bigpond.net.au>, Derek Parnell says...
>> But you as a coder don't need to worry about this because the compiler  =
>>
>> handles all the manipulation for you.
>>
> 
> I think as 'real programmers' ;) :
> "Real programmers can write assembly langauge in any language"
> 
> This is very hard to do in D, but really easy in C.
> 
> The foreach statemente as an example.
> In D, the compiler handles the implementation.
> I want to know how it is implemented.
> 
> 
> In languages where "a" + "b" = "ab" works there could be programmers who doesn't
> see that concating is much more complex than adding a couple of numbers.
> In D, this is a little better, becouse it's hard to find the concating char (I
> don't have it now, becouse of an odd bug in firefox).
> In C/C++ this is better, becouse it was a func, wich indicated how hard it was
> to do.

A crucial difference between C++ and D, is that the compiler understands 
the concept of concatenation. This means that you can concatenate at 
compile time.
const char [] str1 = "a";
const char [] str2 = str1 ~ "b"
creates str2 as a compile-time constant. In this case the concatenation 
has zero run-time cost. You can use it anywhere that a compile-time 
string literal can be used. You couldn't do this with function calls.

> Some programmers may instead of using:
> writef(a,b,c)
> concate them. Wich would be very bad.




More information about the Digitalmars-d mailing list