Do we really need const?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Tue Sep 18 06:39:30 PDT 2007


Regan Heath wrote:
> Janice Caron wrote:
>> On 9/18/07, Regan Heath <regan at netmail.co.nz> wrote:
>>> Bill Baxter wrote:
>>>> Regan Heath wrote:
>>>>> renoX wrote:
>>>>>> Bruce Adams a écrit :
>>>>>>> An example of one that catches me out quite often is:
>>>>>>> strcpy(src,dest) vs. strcpy(dest,src);
>>>>>> Let's try it: do you think you would make the same mistake if you
>>>>>> would call your function this way:
>>>>>> char[50] var_dest, my_src;
>>>>>> strcpy(dest: var_dest, src: my_src)
>>>>> My eyes... aaarghh!
>>>> Is it the particular syntax or the concept you object to?
>>> Not sure, it just makes my skin crawl at the moment.
>>
>> Of course, for copying strings in D, we already have the vastly 
>> superior syntax
>> dst = src;
>>
>> :-)
> 
> You mean of course:
> 
> dst = src.dup
> 
> ;O)

Or:
---
dst[] = src;
---
to copy to a preallocated buffer (like strcpy does).

(Or
---
dst[0..src.length] = src;
---
if src.length < dst.length...)



More information about the Digitalmars-d mailing list