Re: DIP9 -- Redo toString API

2010-12-14 Thread Bruno Medeiros
On 07/12/2010 17:31, Steven Schveighoffer wrote: On Tue, 07 Dec 2010 11:44:56 -0500, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 02/12/2010 21:08, Steven Schveighoffer wrote: On Thu, 02 Dec 2010 11:31:49 -0500, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 21/11/2010

Re: DIP9 -- Redo toString API

2010-12-07 Thread Bruno Medeiros
On 02/12/2010 21:08, Steven Schveighoffer wrote: On Thu, 02 Dec 2010 11:31:49 -0500, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 21/11/2010 17:21, Don wrote: That idea is quite idiotic indeed, no question about it. However, that is not toString() 's idea! The point of toString (at

Re: DIP9 -- Redo toString API

2010-12-07 Thread Steven Schveighoffer
On Tue, 07 Dec 2010 11:44:56 -0500, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 02/12/2010 21:08, Steven Schveighoffer wrote: On Thu, 02 Dec 2010 11:31:49 -0500, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 21/11/2010 17:21, Don wrote: That idea is quite idiotic

Re: DIP9 -- Redo toString API

2010-12-02 Thread Bruno Medeiros
On 21/11/2010 17:21, Don wrote: spir wrote: On Sun, 21 Nov 2010 03:17:57 -0800 Jonathan M Davis jmdavisp...@gmx.com wrote: You're not losing _anything_ out of the deal except that you wouldn't do obj.toString(). Instead you'd do to!string(obj). I'm usually not using toString(), it's

Re: DIP9 -- Redo toString API

2010-12-02 Thread Steven Schveighoffer
On Thu, 02 Dec 2010 11:31:49 -0500, Bruno Medeiros brunodomedeiros+s...@com.gmail wrote: On 21/11/2010 17:21, Don wrote: spir wrote: On Sun, 21 Nov 2010 03:17:57 -0800 Jonathan M Davis jmdavisp...@gmx.com wrote: You're not losing _anything_ out of the deal except that you wouldn't do

Re: DIP9 -- Redo toString API

2010-11-22 Thread Don
Tomek Sowiński wrote: Don nos...@nospam.com napisał(a): The efficiency issues are important, but are not the primary motivation. toString() is just wrong. The idea that there is ONE AND ONLY ONE textual representation of an object, is, frankly, idiotic. I always thought of toString() as an

Re: DIP9 -- Redo toString API

2010-11-22 Thread spir
On Mon, 22 Nov 2010 10:14:03 +0100 Don nos...@nospam.com wrote: Tomek Sowiński wrote: Don nos...@nospam.com napisał(a): The efficiency issues are important, but are not the primary motivation. toString() is just wrong. The idea that there is ONE AND ONLY ONE textual representation of

Re: DIP9 -- Redo toString API

2010-11-22 Thread Don
spir wrote: On Mon, 22 Nov 2010 10:14:03 +0100 Don nos...@nospam.com wrote: Tomek Sowiński wrote: Don nos...@nospam.com napisał(a): The efficiency issues are important, but are not the primary motivation. toString() is just wrong. The idea that there is ONE AND ONLY ONE textual

Re: DIP9 -- Redo toString API

2010-11-22 Thread so
toString lacks flexibility in some (not very common but relevant) cases. That pretty much says that you don't do much of math coding/debugging. It is very common on the other side of the world. -- Using Opera's revolutionary email client: http://www.opera.com/mail/

Re: DIP9 -- Redo toString API

2010-11-22 Thread Steven Schveighoffer
On Sun, 21 Nov 2010 05:10:13 -0500, spir denis.s...@gmail.com wrote: On Thu, 18 Nov 2010 17:21:20 -0500 Steven Schveighoffer schvei...@yahoo.com wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See:

Re: DIP9 -- Redo toString API

2010-11-22 Thread spir
On Mon, 22 Nov 2010 11:02:48 -0500 Steven Schveighoffer schvei...@yahoo.com wrote: On Sun, 21 Nov 2010 05:10:13 -0500, spir denis.s...@gmail.com wrote: On Thu, 18 Nov 2010 17:21:20 -0500 Steven Schveighoffer schvei...@yahoo.com wrote: I just created a new D Improvement Proposal to

Re: DIP9 -- Redo toString API

2010-11-22 Thread Daniel Gibson
spir schrieb: toString is so wrong that it's often the first method most users of most OO language implement -- to ensure vivious bugs won't pass unseen -- to be able to combine representations into more complete representations-- to construct useful feedback about their app in general. When

Re: DIP9 -- Redo toString API

2010-11-21 Thread spir
On Thu, 18 Nov 2010 17:21:20 -0500 Steven Schveighoffer schvei...@yahoo.com wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9 Hello, [Sorry for a partly

Re: DIP9 -- Redo toString API

2010-11-21 Thread Jonathan M Davis
On Sunday 21 November 2010 02:10:13 spir wrote: On Thu, 18 Nov 2010 17:21:20 -0500 Steven Schveighoffer schvei...@yahoo.com wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See:

Re: DIP9 -- Redo toString API

2010-11-21 Thread Pelle Månsson
On 11/21/2010 11:10 AM, spir wrote: What I do not want is tostring be deprecated in any case. The proposal would be OK if it introduced an _alternative_ for the cases (?) where string output efficiency is relevant. The language could/should default to writeTo is toString is not defined, *and*

Re: DIP9 -- Redo toString API

2010-11-21 Thread spir
On Sun, 21 Nov 2010 03:17:57 -0800 Jonathan M Davis jmdavisp...@gmx.com wrote: You're not losing _anything_ out of the deal except that you wouldn't do obj.toString(). Instead you'd do to!string(obj). I'm usually not using toString(), it's supported by the language. What about format(%s:%s,

Re: DIP9 -- Redo toString API

2010-11-21 Thread spir
On Sun, 21 Nov 2010 15:55:10 +0100 Pelle Månsson pelle.mans...@gmail.com wrote: But the key point is that language features like D's toString are far to be used only for _direct_ string output. They are extremely useful for numerous tasks of string manipulation and processing, most of

Re: DIP9 -- Redo toString API

2010-11-21 Thread Dmitry Olshansky
On 21.11.2010 17:08, spir wrote: On Sun, 21 Nov 2010 03:17:57 -0800 Jonathan M Davisjmdavisp...@gmx.com wrote: You're not losing _anything_ out of the deal except that you wouldn't do obj.toString(). Instead you'd do to!string(obj). I'm usually not using toString(), it's supported by the

Re: DIP9 -- Redo toString API

2010-11-21 Thread Michel Fortin
On 2010-11-21 05:10:13 -0500, spir denis.s...@gmail.com said: I consider time space efficiency for string output to be irrelevant, not even a theoretic question. Maybe I simply have never reached points where i t would? Have you ever stepped on a app not running correctly because toStr ing

Re: DIP9 -- Redo toString API

2010-11-21 Thread Nick Sabalausky
spir denis.s...@gmail.com wrote in message news:mailman.532.1290349037.21107.digitalmar...@puremagic.com... On Sun, 21 Nov 2010 15:55:10 +0100 Pelle Månsson pelle.mans...@gmail.com wrote: But the key point is that language features like D's toString are far to be used only for _direct_

Re: DIP9 -- Redo toString API

2010-11-21 Thread Pelle Månsson
On 11/21/2010 03:17 PM, spir wrote: No, just use toString. As said above, I don't want to writeTo, I want the string; and be free to do whatever I want to with it. Being only able to write is... (rather censure). I... don't think you understand what writeTo is supposed to do. Inside

Re: DIP9 -- Redo toString API

2010-11-21 Thread bearophile
Don: The efficiency issues are important, but are not the primary motivation. toString() is just wrong. The idea that there is ONE AND ONLY ONE textual representation of an object, is, frankly, idiotic. To solve that the toString() may take an argument, like a formatting string or an enum,

Re: DIP9 -- Redo toString API

2010-11-21 Thread spir
On Sun, 21 Nov 2010 18:21:48 +0100 Don nos...@nospam.com wrote: spir wrote: On Sun, 21 Nov 2010 03:17:57 -0800 Jonathan M Davis jmdavisp...@gmx.com wrote: You're not losing _anything_ out of the deal except that you wouldn't do obj.toString(). Instead you'd do to!string(obj).

Re: DIP9 -- Redo toString API

2010-11-21 Thread Jacob Carlborg
On 2010-11-21 17:28, Pelle Månsson wrote: On 11/21/2010 03:17 PM, spir wrote: No, just use toString. As said above, I don't want to writeTo, I want the string; and be free to do whatever I want to with it. Being only able to write is... (rather censure). I... don't think you understand what

Re: DIP9 -- Redo toString API

2010-11-21 Thread spir
On Sun, 21 Nov 2010 17:28:09 +0100 Pelle Månsson pelle.mans...@gmail.com wrote: However, writeln can do this: foreach (arg; args) { arg.writeTo((const(char)[] data) { outputbuffer.put(data); }) } thereby removing the need to store the string, and the extra allocations.

Re: DIP9 -- Redo toString API

2010-11-21 Thread Pelle Månsson
On 11/21/2010 09:49 PM, spir wrote: (Sorry for the irony.) Make simple things easy. Have to write a delegate to get feedback... to print a bit of text. (What is hello, world! in D?) Missing the point, are we? Hello world is unchanged.

Re: DIP9 -- Redo toString API

2010-11-21 Thread KennyTM~
On Nov 22, 10 04:49, spir wrote: On Sun, 21 Nov 2010 17:28:09 +0100 Pelle Månssonpelle.mans...@gmail.com wrote: However, writeln can do this: foreach (arg; args) { arg.writeTo((const(char)[] data) { outputbuffer.put(data); }) } thereby removing the need to store the

Re: DIP9 -- Redo toString API

2010-11-21 Thread Pelle Månsson
On 11/21/2010 09:37 PM, Jacob Carlborg wrote: Inside to!string, it would be something like this: string s; arg.writeTo((const(char)[] data) { s ~= data; }); return s; Why can't toString do the same ? Because then you'd have to write it? I'm afraid I don't understand.

Re: DIP9 -- Redo toString API

2010-11-21 Thread Jérôme M. Berger
spir wrote: On Sun, 21 Nov 2010 17:28:09 +0100 Pelle Månsson pelle.mans...@gmail.com wrote: However, writeln can do this: foreach (arg; args) { arg.writeTo((const(char)[] data) { outputbuffer.put(data); }) } thereby removing the need to store the string, and the extra

Re: DIP9 -- Redo toString API

2010-11-21 Thread Jérôme M. Berger
spir wrote: On Sun, 21 Nov 2010 18:21:48 +0100 Don nos...@nospam.com wrote: spir wrote: On Sun, 21 Nov 2010 03:17:57 -0800 Jonathan M Davis jmdavisp...@gmx.com wrote: You're not losing _anything_ out of the deal except that you wouldn't do obj.toString(). Instead you'd do

Re: DIP9 -- Redo toString API

2010-11-21 Thread bearophile
spir: 1. Please bring concrete cases of apps that do not work well because of toString and would work fine just by replacing it with writeTo. writeln is already slow. To print quickly numerical genomic data in D I have had to use printf in some situations. 4. If you want another default

Re: DIP9 -- Redo toString API

2010-11-21 Thread Tomek Sowiński
Don nos...@nospam.com napisał(a): The efficiency issues are important, but are not the primary motivation. toString() is just wrong. The idea that there is ONE AND ONLY ONE textual representation of an object, is, frankly, idiotic. I always thought of toString() as an aid in debugging,

Re: DIP9 -- Redo toString API

2010-11-21 Thread Don
spir wrote: On Sun, 21 Nov 2010 18:21:48 +0100 Don nos...@nospam.com wrote: spir wrote: On Sun, 21 Nov 2010 03:17:57 -0800 Jonathan M Davis jmdavisp...@gmx.com wrote: You're not losing _anything_ out of the deal except that you wouldn't do obj.toString(). Instead you'd do to!string(obj).

Re: DIP9 -- Redo toString API

2010-11-19 Thread Jacob Carlborg
On 2010-11-18 23:21, Steven Schveighoffer wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9 -Steve Why do we have to remove toString, can't toString call writeTo and

Re: DIP9 -- Redo toString API

2010-11-19 Thread Lars T. Kyllingstad
On Fri, 19 Nov 2010 10:22:29 +0100, Jacob Carlborg wrote: On 2010-11-18 23:21, Steven Schveighoffer wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9 -Steve Why

Re: DIP9 -- Redo toString API

2010-11-19 Thread Fawzi Mohamed
On 19-nov-10, at 10:22, Jacob Carlborg wrote: On 2010-11-18 23:21, Steven Schveighoffer wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9 -Steve Why do we have

Re: DIP9 -- Redo toString API

2010-11-19 Thread Fawzi Mohamed
On 19-nov-10, at 11:13, Lars T. Kyllingstad wrote: On Fri, 19 Nov 2010 10:22:29 +0100, Jacob Carlborg wrote: On 2010-11-18 23:21, Steven Schveighoffer wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See:

Re: DIP9 -- Redo toString API

2010-11-19 Thread Steven Schveighoffer
On Thu, 18 Nov 2010 20:18:19 -0500, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, November 18, 2010 14:21:20 Steven Schveighoffer wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See:

Re: DIP9 -- Redo toString API

2010-11-19 Thread Steven Schveighoffer
On Fri, 19 Nov 2010 02:27:07 -0500, Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote: On Thu, 18 Nov 2010 17:21:20 -0500, Steven Schveighoffer wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See:

Re: DIP9 -- Redo toString API

2010-11-19 Thread Steven Schveighoffer
On Thu, 18 Nov 2010 17:21:20 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9 I've made suggested changes,

Re: DIP9 -- Redo toString API

2010-11-19 Thread bearophile
Steven Schveighoffer: I've made suggested changes, please review again. Good, thank you. Just a note: a DIP is a public document so it's better to encourage good idioms inside it. null to represent empty arrays/strings is a bad practice, so instead of this: void writeTo(scope delegate(in

Re: DIP9 -- Redo toString API

2010-11-19 Thread Steven Schveighoffer
On Fri, 19 Nov 2010 09:14:07 -0500, bearophile bearophileh...@lycos.com wrote: Steven Schveighoffer: I've made suggested changes, please review again. Good, thank you. Just a note: a DIP is a public document so it's better to encourage good idioms inside it. null to represent empty

Re: DIP9 -- Redo toString API

2010-11-19 Thread bearophile
Steven Schveighoffer: Who said setting an array to null is bad practice? I disagree. null is a better way to represent it, because it sets both the ptr and the length to 0, while only sets the length to 0. char[] arr = ; assert(arr == null); // passes assert(arr is null); //

Re: DIP9 -- Redo toString API

2010-11-19 Thread Jonathan M Davis
On Friday, November 19, 2010 05:54:15 Steven Schveighoffer wrote: On Thu, 18 Nov 2010 17:21:20 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See:

Re: DIP9 -- Redo toString API

2010-11-19 Thread Pillsy
Steven Schveighoffer Wrote: On Thu, 18 Nov 2010 17:21:20 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9

Re: DIP9 -- Redo toString API

2010-11-19 Thread Steven Schveighoffer
On Fri, 19 Nov 2010 12:51:29 -0500, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, November 19, 2010 05:54:15 Steven Schveighoffer wrote: On Thu, 18 Nov 2010 17:21:20 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: I just created a new D Improvement Proposal to fix the

Re: DIP9 -- Redo toString API

2010-11-19 Thread Jonathan M Davis
On Friday, November 19, 2010 10:26:40 Steven Schveighoffer wrote: On Fri, 19 Nov 2010 12:51:29 -0500, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, November 19, 2010 05:54:15 Steven Schveighoffer wrote: On Thu, 18 Nov 2010 17:21:20 -0500, Steven Schveighoffer

DIP9 -- Redo toString API

2010-11-18 Thread Steven Schveighoffer
I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9 -Steve

Re: DIP9 -- Redo toString API

2010-11-18 Thread bearophile
Steven Schveighoffer: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. Thank you for writing the DIP. It looks interesting. I suggest to add an example, the implementation of toString() and writeTo() for a simple struct like this (or a

Re: DIP9 -- Redo toString API

2010-11-18 Thread Jonathan M Davis
On Thursday, November 18, 2010 14:21:20 Steven Schveighoffer wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9 Looks good overall, but I would point out that the text

Re: DIP9 -- Redo toString API

2010-11-18 Thread Lars T. Kyllingstad
On Thu, 18 Nov 2010 17:21:20 -0500, Steven Schveighoffer wrote: I just created a new D Improvement Proposal to fix the toString problem I brought up several posts ago. See: http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP9 I think it's best to leave out the '%' from the format