[antlr-interest] FEATURE REQUEST: std::stream -- remove

Arnar Birgisson arnarb at oddi.is
Mon Feb 16 02:03:26 PST 2004


Hello all,

Sun, 15. Feb 2004 kl. 09:23:08 +0200 skrifa­i Ruslan Zasukhin:
> So I dream, that ANTLR C++ runtime sources of Lexer / Parser
> depend NOT on std::streams, but on some C++ interface class of stream
> 
>     I_Istream
>     I_OStream

I beg to differ. I see the std::stream definition as an interface declaration, since there are many implementations of it. Therefore, I see no reason why ANTLR should implement another interface layer to encapsulate the std::stream interface.

The std::stream library was designed (IMHO successfully) to be easy to extend and tack on top of various input/output systems. Having such a standard greatly simplifies development in my case, instead of each library or project you use having it's own interface declarations. That only means that in your own project, you need wrappers to make all those stream interfaces work together, which is kind of ironic if most of them use the same stream implementation behind those interfaces.

I say ANTLR should stick to std::stream, whereas that is already such an interface as you describe, and a standard one too. Chances are that users already have std::stream wrappers for their custom streams (at least that has been my case).

> And ANTLR distribution have include implementation of these interfaces for
> STD::stream.
> 
> 1) STD::streams will be encapsulated into this .cpp file only
> 
> 2) we will get ability to use other implementations of streams if we need.
> 
> For example, in our Valentina DBMS we have own such stream interfaces,
> And we have a lots of implementations of them
>     Stream on STD file
>     Stream on our own file class
>     Stream on socket
>     Stream on Cached Files.
> 
> As you know DBMS have caching, and we can use files via our own caching.
> But because ANTLR depend on std::stream we cannot use caching files with it.
> This put down performance.

Writing std::stream implementations is easy, usually only a matter of extending std::streambuf. -- In your case, writing a std::stream wrapper over your interfaces is also an option, and could benefit you in more librarires than just ANTLR.

> I believe using of interfaces is flexible and good OO design feature.

This is a very good point, and I totally agree. However, in my opinion, std::stream is just an interface declaration (and a good one), not an implementation. For that we have SGI, Microsoft, etc.

Arnar


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list