const?? When and why? This is ugly!

Don nospam at nospam.com
Mon Mar 9 08:28:20 PDT 2009


Andrei Alexandrescu wrote:
> Don wrote:
>> Andrei Alexandrescu wrote:
>>> As far as signatures of functions in std.string, I agree that those 
>>> not needing a string of immutable characters should just accept in 
>>> Char[] (where Char is one of the three character types). That should 
>>> make people using mutable and immutable strings equally joyous.
>>
>> Also std.conv (especially the scheduled-to-be-deprecated toInt(), etc),
>> and probably also the functions in std.file, such as exists().
> 
> Yah. That's fixed already, but I concluded I can't check in my changes 
> to phobos until a few bugs are fixed, notably 2674 
> (http://d.puremagic.com/issues/show_bug.cgi?id=2674). Please vote up :o).
> 
> 
> Andrei
Yes.
BTW, in my own code, a major reason why string -> const(char)[] is such 
a necessary change is that std.stream.readLine() returns 'char[]', not 
'string'. So you can hardly do anything without a cast or an idup.

Don.



More information about the Digitalmars-d mailing list