www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Idea: writeln and file functions that return the data passed to them

reply "ixid" <nuaccount gmail.com> writes:
Perhaps there is already a way to do this. With the UFCS one 
tends to make elegant chains of statements, it would be useful to 
have writeln and file functions that can easily be dropped in the 
middle of such chains without having to alter the lay out of 
one's program. Rather than returning void it would be nice to 
have a version of these that will pass along the data that was 
passed to them.
Jun 12 2012
next sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 12.06.2012 16:12, ixid wrote:
 Perhaps there is already a way to do this. With the UFCS one tends to
 make elegant chains of statements, it would be useful to have writeln
 and file functions that can easily be dropped in the middle of such
 chains without having to alter the lay out of one's program.

Problem is ... there might not be string representation of output, it's all sent to the device in parts lazily. (e.g. writeln(a, b, c) ) And requiring it to allocate temporary buffer just so you can put it in a cool expression chain... beats me. Rather than
 returning void it would be nice to have a version of these that will
 pass along the data that was passed to them.

-- Dmitry Olshansky
Jun 12 2012
prev sibling parent "Simen Kjaeraas" <simen.kjaras gmail.com> writes:
On Tue, 12 Jun 2012 14:12:19 +0200, ixid <nuaccount gmail.com> wrote:

 Perhaps there is already a way to do this. With the UFCS one tends to  
 make elegant chains of statements, it would be useful to have writeln  
 and file functions that can easily be dropped in the middle of such  
 chains without having to alter the lay out of one's program. Rather than  
 returning void it would be nice to have a version of these that will  
 pass along the data that was passed to them.

T passAlong( alias F, T )( T args ) { alias unaryFun!F fn; fn( args ); return args; } Usage: [1,2,3].passAlong!writeln().UFCS(); Happy?
Jun 13 2012