digitalmars.D - Advocate OutBuffer.write return reference to itself rather than void
-
Lynn Allan
(31/31)
Sep 14 2004
- Vathix (14/45) Sep 14 2004 return
- Lynn Allan (43/97) Sep 24 2004 But using the "With" statement, you get conflicts with imports and you e...
- Regan Heath (8/112) Sep 26 2004 I tend to agree with you, in fact as the method returns absolutely nothi...
- Sean Kelly (4/8) Sep 26 2004 Yup. That's already the way things work in my stream prototype:
- Regan Heath (9/19) Sep 26 2004 Cool.
<alert comment="newbie"> If appropriate, I would like to advocate that myOutBuffer.write(arg) return a reference to itself rather than the current practice of not returning anything (i.e. void). I believe this would lead to improved syntax and possibly encourage wider usage of OutBuffer. My impression is that it is more efficient to use a series of myOutBuffer.write(arg) calls rather than appending with "~". However, the resulting code seems more "tedious" and verbose than it has to be because myOutBuffer.write(arg) doesn't return anything. Inefficient but concise: writefln(lastName ~ ", " ~ firstName ~ " " ~ middleInitial ~ "."); More efficient but tediously verbose: myOutBuffer.reserve(100); myOutBuffer.write(lastName); myOutBuffer.write(", "); myOutBuffer.write(firstName); myOutBuffer.write(" "); myOutBuffer.write(middleInitial); myOutBuffer.write("."); writefln(myOutBuffer.toString()); As I recall, C++ and/or Java would allow "cascading / stringing together" of the above series of write calls because it returned a pointer/reference to itself rather than myOutBuffer.write(arg) returning void. This would allow the following syntax which, to me, is preferred: myOutBuffer.write(lastName).write(", ").write(firstName).write(" ").write(middleInitial).write("."); Am I missing or overlooking something? No doubt easier said than done, but it seems like this change might be straightforward to implement. After all, my impression is that the "~" operator is returning a reference to its object to allow the concatenation to happen. </alert>
Sep 14 2004
"Lynn Allan" <l_d_allan adelphia.net> wrote in message news:ci8f8q$l5n$1 digitaldaemon.com...<alert comment="newbie"> If appropriate, I would like to advocate that myOutBuffer.write(arg)returna reference to itself rather than the current practice of not returning anything (i.e. void). I believe this would lead to improved syntax and possibly encourage wider usage of OutBuffer. My impression is that it is more efficient to use a series of myOutBuffer.write(arg) calls rather than appending with "~". However, the resulting code seems more "tedious" and verbose than it has to be because myOutBuffer.write(arg) doesn't return anything. Inefficient but concise: writefln(lastName ~ ", " ~ firstName ~ " " ~ middleInitial ~ "."); More efficient but tediously verbose: myOutBuffer.reserve(100); myOutBuffer.write(lastName); myOutBuffer.write(", "); myOutBuffer.write(firstName); myOutBuffer.write(" "); myOutBuffer.write(middleInitial); myOutBuffer.write("."); writefln(myOutBuffer.toString()); As I recall, C++ and/or Java would allow "cascading / stringing together"ofthe above series of write calls because it returned a pointer/reference to itself rather than myOutBuffer.write(arg) returning void. This would allow the following syntax which, to me, is preferred: myOutBuffer.write(lastName).write(", ").write(firstName).write(" ").write(middleInitial).write("."); Am I missing or overlooking something? No doubt easier said than done, but it seems like this change might be straightforward to implement. Afterall,my impression is that the "~" operator is returning a reference to its object to allow the concatenation to happen. </alert>with(myOutBuffer) { reserve(100); write("fe"); write("fi"); write("fo"); write("fum"); } Even better?
Sep 14 2004
But using the "With" statement, you get conflicts with imports and you end up with code like: #import std.outbuffer; #import std.string; #import std.stdio; #void main() // or "Vathix" <vathixSpamFix dprogramming.com> wrote in message news:ci8hkf$n2o$1 digitaldaemon.com..."Lynn Allan" <l_d_allan adelphia.net> wrote in message news:ci8f8q$l5n$1 digitaldaemon.com...the<alert comment="newbie"> If appropriate, I would like to advocate that myOutBuffer.write(arg)returna reference to itself rather than the current practice of not returning anything (i.e. void). I believe this would lead to improved syntax and possibly encourage wider usage of OutBuffer. My impression is that it is more efficient to use a series of myOutBuffer.write(arg) calls rather than appending with "~". However,becauseresulting code seems more "tedious" and verbose than it has to betogether"myOutBuffer.write(arg) doesn't return anything. Inefficient but concise: writefln(lastName ~ ", " ~ firstName ~ " " ~ middleInitial ~ "."); More efficient but tediously verbose: myOutBuffer.reserve(100); myOutBuffer.write(lastName); myOutBuffer.write(", "); myOutBuffer.write(firstName); myOutBuffer.write(" "); myOutBuffer.write(middleInitial); myOutBuffer.write("."); writefln(myOutBuffer.toString()); As I recall, C++ and/or Java would allow "cascading / stringingoftothe above series of write calls because it returned a pointer/referenceallowitself rather than myOutBuffer.write(arg) returning void. This wouldbutthe following syntax which, to me, is preferred: myOutBuffer.write(lastName).write(", ").write(firstName).write(" ").write(middleInitial).write("."); Am I missing or overlooking something? No doubt easier said than done,it seems like this change might be straightforward to implement. Afterall,my impression is that the "~" operator is returning a reference to its object to allow the concatenation to happen. </alert>with(myOutBuffer) { reserve(100); write("fe"); write("fi"); write("fo"); write("fum"); } Even better?
Sep 24 2004
I tend to agree with you, in fact as the method returns absolutely nothing at the moment I cannot see what disadvantage there is to what you propose. written? On Fri, 24 Sep 2004 08:09:07 -0600, Lynn Allan <l_d_allan adelphia.net> wrote:But using the "With" statement, you get conflicts with imports and you end up with code like: #import std.outbuffer; #import std.string; #import std.stdio; #void main() // or "Vathix" <vathixSpamFix dprogramming.com> wrote in message news:ci8hkf$n2o$1 digitaldaemon.com...-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/"Lynn Allan" <l_d_allan adelphia.net> wrote in message news:ci8f8q$l5n$1 digitaldaemon.com...the<alert comment="newbie"> If appropriate, I would like to advocate that myOutBuffer.write(arg)returna reference to itself rather than the current practice of notreturninganything (i.e. void). I believe this would lead to improved syntax and possibly encourage wider usage of OutBuffer. My impression is that it is more efficient to use a series of myOutBuffer.write(arg) calls rather than appending with "~". However,becauseresulting code seems more "tedious" and verbose than it has to betogether"myOutBuffer.write(arg) doesn't return anything. Inefficient but concise: writefln(lastName ~ ", " ~ firstName ~ " " ~ middleInitial ~ "."); More efficient but tediously verbose: myOutBuffer.reserve(100); myOutBuffer.write(lastName); myOutBuffer.write(", "); myOutBuffer.write(firstName); myOutBuffer.write(" "); myOutBuffer.write(middleInitial); myOutBuffer.write("."); writefln(myOutBuffer.toString()); As I recall, C++ and/or Java would allow "cascading / stringingoftothe above series of write calls because it returned apointer/referenceallowitself rather than myOutBuffer.write(arg) returning void. This wouldbutthe following syntax which, to me, is preferred: myOutBuffer.write(lastName).write(", ").write(firstName).write(" ").write(middleInitial).write("."); Am I missing or overlooking something? No doubt easier said than done,it seems like this change might be straightforward to implement. Afterall,my impression is that the "~" operator is returning a reference to its object to allow the concatenation to happen. </alert>with(myOutBuffer) { reserve(100); write("fe"); write("fi"); write("fo"); write("fum"); } Even better?
Sep 26 2004
In article <opseyewchn5a2sq9 digitalmars.com>, Regan Heath says...I tend to agree with you, in fact as the method returns absolutely nothing at the moment I cannot see what disadvantage there is to what you propose. written?Yup. That's already the way things work in my stream prototype: http://home.f4.ca/sean/d/stream.d Sean
Sep 26 2004
On Sun, 26 Sep 2004 22:06:22 +0000 (UTC), Sean Kelly <sean f4.ca> wrote:In article <opseyewchn5a2sq9 digitalmars.com>, Regan Heath says...Cool. I see you're setting a 'BADBIT' when it fails to write/read the specified length of data, and have a throwOn method for setting what bits cause exceptions. Great idea! It neatly solves the 'when does it make sense to throw an exception' problem by giving the programmer the choice. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/I tend to agree with you, in fact as the method returns absolutely nothing at the moment I cannot see what disadvantage there is to what you propose. written?Yup. That's already the way things work in my stream prototype: http://home.f4.ca/sean/d/stream.d
Sep 26 2004