www.digitalmars.com         C & C++   DMDScript  

D - Support for cout and cin

reply ranjit_bh hotmail.com writes:
I have just been introduced to D. But if there is support for  c++ why was not
the cout or the cin operator not allowed for in D
Mar 10 2003
next sibling parent "Sean L. Palmer" <seanpalmer directvinternet.com> writes:
D is more properly a descendant of C than of C++.

Sean

<ranjit_bh hotmail.com> wrote in message
news:b4jtvq$edd$1 digitaldaemon.com...
 I have just been introduced to D. But if there is support for  c++ why was

 the cout or the cin operator not allowed for in D

Mar 10 2003
prev sibling parent Ilya Minkov <midiclub 8ung.at> writes:
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

ranjit_bh hotmail.com wrote:
 I have just been introduced to D. But if there is support for  c++ why was not
 the cout or the cin operator not allowed for in D

You can write a library, but you're almost on your own. You can take advantage of D support for standard C runtime, but not C++ which is too clumnsy and not a target for D. We want something more elegant than C++. I have here an implementation written for an ehanced C compiler supporting operator overloading, which is though incomplete, might give you an idea of how to do it if you like. It was written by the maintainer of LCC-Win32 and only works in it, should requiere a moderate amount of change and refractoring to work in D. HINT: you're not changing this libarary but writing a new one "inspired" by it and the original C++ iostream. :) For you to get started: the library expects the main application to create the cout buffer. A buffer can either be a file, of a dynamic cstring. If you want it as a file, you open the file as usual and pass it to "iostream_new_from_file(FILE *)". In the case you want it to be a string, you use "iostream_new_from_string(char * buf, int length)". If you pass NULL as buf it shall allocate memory as requiered all by itself. Length limits the length, unless it is 0. This would be simplified in D. Hope this can be helpful. -i.
Mar 12 2003