www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Streams, SWIG and C++

reply John Fletcher <J.P.Fletcher aston.ac.uk> writes:
Now that D has streams is it possible to integrate output from C++
streams?

I can already do this using SWIG to go from C++ to Ruby or Python.  In
those cases there is a function name (__str__) which hooks into the
target language.

There are also function names for operator overloading e.g. __plus__.

Is there the equivalent for D?

I have in mind to use this to interface classes for symbolic algebra.

John
Jun 09 2004
parent reply "Walter" <newshound digitalmars.com> writes:
Sure. See www.digitalmars.com/d/operatoroverloading.html


"John Fletcher" <J.P.Fletcher aston.ac.uk> wrote in message
news:40C6F5F6.745AC86C aston.ac.uk...
 Now that D has streams is it possible to integrate output from C++
 streams?

 I can already do this using SWIG to go from C++ to Ruby or Python.  In
 those cases there is a function name (__str__) which hooks into the
 target language.

 There are also function names for operator overloading e.g. __plus__.

 Is there the equivalent for D?

 I have in mind to use this to interface classes for symbolic algebra.

 John
Jun 09 2004
parent reply John Fletcher <J.P.Fletcher aston.ac.uk> writes:
Walter wrote:

 Sure. See www.digitalmars.com/d/operatoroverloading.html

 "John Fletcher" <J.P.Fletcher aston.ac.uk> wrote in message
 news:40C6F5F6.745AC86C aston.ac.uk...
 Now that D has streams is it possible to integrate output from C++
 streams?
I now have the numerical operators working. Please, is there an example somewhere of D coding using output streams? John
Jun 10 2004
parent reply Brad Anderson <brad dsource.dot.org> writes:
I know I attempted to answer an Arcane Jill question and didn't fully 
understand it, but with this and other discussions about Streams, I 
wanted to mention Mango.io again.

http://mango.dsource.org or http://www.dsource.org/projects/mango

Mango.io is super-efficient since it avoids the overhead of system calls 
wherever possible (always buffered). It's also far more flexible than 
the Streams stuff could ever be: Sockets, tokens, files, memory-mapped 
IO, bidi OutBuffer-style IO, extensible Reader/Writer framework, simple 
mechanism for binding ones own classes using IReadable & IWritable, 
CompositeIO, Serialization etc. etc. all work together seamlessly and 
extensibly.

Each of those items is either a non-integrated design, or non-existent, 
in Phobos.

Here is an example:
 // open a file for reading
 FileConduit fc = new FileConduit ("test.txt", FileStyle.ReadExisting);

 // create a Token and bind it to both the file and a line-tokenizer
 CompositeToken line = new CompositeToken (Tokenizers.line, fc);

 // read file a line at a time. Method next() returns false when no
 // more delimiters are found.
 // Note there may be an unterminated line at eof
 while (line.next() || line.getLength())
     Stdout.put(line).cr();
And you can use the C++ >> and << as well as the put() and get(). I am thoroughly enjoying using Mango for its http server as well as servlet container, too. But underlying it all is a great IO library that people should check out. My vote is that *this* is what makes its way into Phobos, or at least Deimos. Cheers, Brad John Fletcher wrote:
 
 Walter wrote:
 
 
Sure. See www.digitalmars.com/d/operatoroverloading.html

"John Fletcher" <J.P.Fletcher aston.ac.uk> wrote in message
news:40C6F5F6.745AC86C aston.ac.uk...

Now that D has streams is it possible to integrate output from C++
streams?
I now have the numerical operators working. Please, is there an example somewhere of D coding using output streams? John
Jun 10 2004
next sibling parent Arcane Jill <Arcane_member pathlink.com> writes:
In article <caaecp$1klt$1 digitaldaemon.com>, Brad Anderson says...

I know I attempted to answer an Arcane Jill question and didn't fully 
understand it, but with this and other discussions about Streams, I 
wanted to mention Mango.io again.

http://mango.dsource.org or http://www.dsource.org/projects/mango

Mango.io is super-efficient since it avoids the overhead of system calls 
wherever possible (always buffered). It's also far more flexible than 
the Streams stuff could ever be: Sockets, tokens, files, memory-mapped 
IO, bidi OutBuffer-style IO, extensible Reader/Writer framework, simple 
mechanism for binding ones own classes using IReadable & IWritable, 
CompositeIO, Serialization etc. etc. all work together seamlessly and 
extensibly.
Hey, I'm really GLAD you mentioned it again. I hadn't got around to looking at it. Well - what can I say? Wow!
I am thoroughly enjoying using Mango for its http server as well as 
servlet container, too.  But underlying it all is a great IO library 
that people should check out.  My vote is that *this* is what makes its 
way into Phobos, or at least Deimos.
It's more than welcome in Deimos. By all means! Just copy it in there! Arcane Jill
Jun 10 2004
prev sibling next sibling parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
"Brad Anderson" <brad dsource.dot.org> wrote in message
news:caaecp$1klt$1 digitaldaemon.com...
 I know I attempted to answer an Arcane Jill question and didn't fully
 understand it, but with this and other discussions about Streams, I
 wanted to mention Mango.io again.

 http://mango.dsource.org or http://www.dsource.org/projects/mango

 Mango.io is super-efficient since it avoids the overhead of system calls
 wherever possible (always buffered). It's also far more flexible than
 the Streams stuff could ever be: Sockets, tokens, files, memory-mapped
 IO, bidi OutBuffer-style IO, extensible Reader/Writer framework, simple
 mechanism for binding ones own classes using IReadable & IWritable,
 CompositeIO, Serialization etc. etc. all work together seamlessly and
 extensibly.

 Each of those items is either a non-integrated design, or non-existent,
 in Phobos.

 Here is an example:
  > // open a file for reading
  > FileConduit fc = new FileConduit ("test.txt", FileStyle.ReadExisting);
  >
  > // create a Token and bind it to both the file and a line-tokenizer
  > CompositeToken line = new CompositeToken (Tokenizers.line, fc);
  >
  > // read file a line at a time. Method next() returns false when no
  > // more delimiters are found.
  > // Note there may be an unterminated line at eof
  > while (line.next() || line.getLength())
  >     Stdout.put(line).cr();

 And you can use the C++ >> and << as well as the put() and get().

 I am thoroughly enjoying using Mango for its http server as well as
 servlet container, too.  But underlying it all is a great IO library
 that people should check out.  My vote is that *this* is what makes its
 way into Phobos, or at least Deimos.
Even though I've dipped in only briefly, I think Mango at least needs to be considered. If we have two or more competing streams implementations, I think we should have a formal review of them, and either elect a standard one, or make recommendations to big-W to do the same. Come July, I'll gladly organise/participate in such a review.
Jun 10 2004
prev sibling parent John Reimer <jjreimer telus.net> writes:
Brad Anderson wrote:

 I know I attempted to answer an Arcane Jill question and didn't fully
 understand it, but with this and other discussions about Streams, I
 wanted to mention Mango.io again.
 
 http://mango.dsource.org or http://www.dsource.org/projects/mango
 
 Mango.io is super-efficient since it avoids the overhead of system calls
 wherever possible (always buffered). It's also far more flexible than
 the Streams stuff could ever be: Sockets, tokens, files, memory-mapped
 IO, bidi OutBuffer-style IO, extensible Reader/Writer framework, simple
 mechanism for binding ones own classes using IReadable & IWritable,
 CompositeIO, Serialization etc. etc. all work together seamlessly and
 extensibly.
 
 Each of those items is either a non-integrated design, or non-existent,
 in Phobos.
 
 Here is an example:
  > // open a file for reading
  > FileConduit fc = new FileConduit ("test.txt", FileStyle.ReadExisting);
  >
  > // create a Token and bind it to both the file and a line-tokenizer
  > CompositeToken line = new CompositeToken (Tokenizers.line, fc);
  >
  > // read file a line at a time. Method next() returns false when no
  > // more delimiters are found.
  > // Note there may be an unterminated line at eof
  > while (line.next() || line.getLength())
  >     Stdout.put(line).cr();
 
 And you can use the C++ >> and << as well as the put() and get().
 
 I am thoroughly enjoying using Mango for its http server as well as
 servlet container, too.  But underlying it all is a great IO library
 that people should check out.  My vote is that *this* is what makes its
 way into Phobos, or at least Deimos.
 
 Cheers,
 Brad
This second this (or third?). Mango is a finely designed library and definitely merits serious consideration for future official integration into the D toolset. I hope more people will realize the careful design that appears to have gone into this library by it's author. It's definitely not something just slapped together. Of the stream tools currently available, mango.io appears to be the fastest growing, most well documented, and most extensible/customizable. Cheers to Kris for his efforts. I hope such efforts are rewarded. I think we should seriously start to discuss/evaluate mango before delving too much into new projects. More people should download it, evaluate it, and discuss it. Given it's solid design, it would also be an excellent basis for future improvements. Later, John R.
Jun 10 2004