endsWith: wrong function call, no error

Chris wendlec at tcd.ie
Mon Oct 21 08:54:23 PDT 2013


On Monday, 21 October 2013 at 15:38:47 UTC, David Eagen wrote:
> On Monday, 21 October 2013 at 15:18:18 UTC, monarch_dodra wrote:
>>
>> It's a feature.
>
> I actually like that feature. It's me compose long strings in 
> an easily viewable way without having to use concatenation and 
> therefore additional allocation. Or, even to just comment on 
> indvidual lines
>
> string command =
>      "/usr/bin/rm -rf / " // Don't worry, it'll be fine...
>      ">/dev/null 2>/dev/null" // This way nobody will know 
> about it.

Well, in my program it was a bug that could comfortably hide for 
quite a while. It didn't really matter until now, because the 
program worked in spite of the bug. Only recent changes (today) 
brought it to light. If it does more harm than good, than it 
should be removed. It's too easy to forget a comma in an array or 
in a function like endsWith. What is more, this type of bug might 
only become apparent after a long long time. If you have

auto list = ["Joseph", "Mary", "Peter", "Ustinov", "Django" 
"Pope"];

and Django and Pope are the least likely go be selected, it can 
take a while until you realize that there's a bug. For my part, 
I've lived happily without this feature.


More information about the Digitalmars-d mailing list