Re: std.string.chomp error

2010-08-10 Thread Lars T. Kyllingstad
On Mon, 09 Aug 2010 17:35:56 -0700, Jonathan M Davis wrote: On Monday, August 09, 2010 17:09:03 simendsjo wrote: On 10.08.2010 02:09, Jonathan M Davis wrote: On Monday, August 09, 2010 16:59:07 bearophile wrote: simendsjo: Ahem.. :) Yes, I did miss your answer! How I got fooled by the

Re: std.string.chomp error

2010-08-10 Thread Jonathan M Davis
On Tuesday 10 August 2010 00:30:37 Lars T. Kyllingstad wrote: No, using 'is' won't work. Check this out: int[] a; assert (a == null); assert (a is null); a = new int[10]; a.length = 0; assert (a == null); assert (a !is null); The thing is, '==' tests whether two

Re: std.string.chomp error

2010-08-10 Thread Lars T. Kyllingstad
On Tue, 10 Aug 2010 01:48:17 -0700, Jonathan M Davis wrote: On Tuesday 10 August 2010 00:30:37 Lars T. Kyllingstad wrote: No, using 'is' won't work. Check this out: int[] a; assert (a == null); assert (a is null); a = new int[10]; a.length = 0; assert (a == null);

Re: std.string.chomp error

2010-08-10 Thread bearophile
Lars T. Kyllingstad: There, I don't agree with you. Arrays are a sort of pseudo-reference type, so I don't mind 'null' being a sort of pseudo-null in that context. Actually, I find it to be quite elegant. It's a matter of taste, I guess. I suggest you to write down the things you don't

Re: std.string.chomp error

2010-08-10 Thread Lars T. Kyllingstad
On Tue, 10 Aug 2010 07:50:34 -0400, bearophile wrote: Lars T. Kyllingstad: There, I don't agree with you. Arrays are a sort of pseudo-reference type, so I don't mind 'null' being a sort of pseudo-null in that context. Actually, I find it to be quite elegant. It's a matter of taste, I

Re: std.string.chomp error

2010-08-10 Thread bearophile
Lars T. Kyllingstad: I like how it is designed now, that was my point. Sorry, I misread you.

Re: std.string.chomp error

2010-08-10 Thread Jonathan M Davis
On Tuesday 10 August 2010 02:34:33 Lars T. Kyllingstad wrote: I guess it depends on what behaviour you're after. In the present case, if you want chomp(a, null) and chomp(a, ) to do the same thing, then you should use '=='. If you want chomp(a, ) to simply do nothing, use 'is'. I just

std.string.chomp error

2010-08-09 Thread simendsjo
The documentation says /*** * Returns s[] sans trailing delimiter[], if any. * If delimiter[] is null, removes trailing CR, LF, or CRLF, if any. */ To adhere to the documentation, chomp must be changed from: C[] chomp(C, C1)(C[] s, in C1[] delimiter) {

Re: std.string.chomp error

2010-08-09 Thread Lars T. Kyllingstad
On Mon, 09 Aug 2010 18:58:36 +0200, simendsjo wrote: The documentation says /*** * Returns s[] sans trailing delimiter[], if any. * If delimiter[] is null, removes trailing CR, LF, or CRLF, if any. */ To adhere to the documentation, chomp must be

Re: std.string.chomp error

2010-08-09 Thread bearophile
Lars T. Kyllingstad: Either that, or the documentation for it needs to be changed. Anyway, it would be great if you'd report this. A really basic unit testing is able to catch an error like this. This means Phobos needs more unit tests. Stuff that may be added to that unittest: import

Re: std.string.chomp error

2010-08-09 Thread simendsjo
On 09.08.2010 19:16, Lars T. Kyllingstad wrote: On Mon, 09 Aug 2010 18:58:36 +0200, simendsjo wrote: The documentation says /*** * Returns s[] sans trailing delimiter[], if any. * If delimiter[] is null, removes trailing CR, LF, or CRLF, if any. */

Re: std.string.chomp error

2010-08-09 Thread simendsjo
On 09.08.2010 23:58, bearophile wrote: simendsjo: Ok; http://d.puremagic.com/issues/show_bug.cgi?id=4608 You seem to have missed my answer :-) Bye, bearophile No, but I don't know if it's the documentation or implementation that's correct.

Re: std.string.chomp error

2010-08-09 Thread simendsjo
On 09.08.2010 19:34, bearophile wrote: Lars T. Kyllingstad: Either that, or the documentation for it needs to be changed. Anyway, it would be great if you'd report this. A really basic unit testing is able to catch an error like this. This means Phobos needs more unit tests. Stuff that may

Re: std.string.chomp error

2010-08-09 Thread bearophile
simendsjo: Ahem.. :) Yes, I did miss your answer! How I got fooled by the preview pane and never noticed the scrollbar. No problem, it happens, don't worry. I cannot see how your other bug report relates to this though. My other bug report is about this line in your code: if (delimiter ==

Re: std.string.chomp error

2010-08-09 Thread Jonathan M Davis
On Monday, August 09, 2010 16:59:07 bearophile wrote: simendsjo: Ahem.. :) Yes, I did miss your answer! How I got fooled by the preview pane and never noticed the scrollbar. No problem, it happens, don't worry. I cannot see how your other bug report relates to this though. My other

Re: std.string.chomp error

2010-08-09 Thread simendsjo
On 10.08.2010 02:09, Jonathan M Davis wrote: On Monday, August 09, 2010 16:59:07 bearophile wrote: simendsjo: Ahem.. :) Yes, I did miss your answer! How I got fooled by the preview pane and never noticed the scrollbar. No problem, it happens, don't worry. I cannot see how your other bug

Re: std.string.chomp error

2010-08-09 Thread bearophile
Jonathan M Davis: Why, because it should be if(delimiter is null) or just if(!delimiter) if (delimiter.length == 0) Or if (!delimiter.length) Bye, bearophile

Re: std.string.chomp error

2010-08-09 Thread simendsjo
On 10.08.2010 03:08, bearophile wrote: Jonathan M Davis: Why, because it should be if(delimiter is null) or just if(!delimiter) if (delimiter.length == 0) Or if (!delimiter.length) Bye, bearophile Isn't that very different things? You cannot use .length if delimiter is null.

Re: std.string.chomp error

2010-08-09 Thread Jonathan M Davis
On Monday, August 09, 2010 18:12:11 simendsjo wrote: On 10.08.2010 03:08, bearophile wrote: Jonathan M Davis: Why, because it should be if(delimiter is null) or just if(!delimiter) if (delimiter.length == 0) Or if (!delimiter.length) Bye, bearophile Isn't