FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

removal of C++ stream syntax (<< & >>) ?

 
Post new topic   Reply to topic     Forum Index -> Mango
View previous topic :: View next topic  
Author Message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Wed Oct 13, 2004 7:51 pm    Post subject: removal of C++ stream syntax (<< & >>) ? Reply with quote

This has been on the cards for a while: what do people think?

Edit: the C++ syntax will remain


Last edited by kris on Sun Nov 07, 2004 10:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
Ivan Senji



Joined: 03 Sep 2004
Posts: 8
Location: Zagreb, Croatia

PostPosted: Thu Oct 14, 2004 7:51 am    Post subject: Re: removal of C++ stream syntax (<< & >>) f Reply with quote

kris wrote:
This has been on the cards for a while: what do people think?


No! Don't do it. I really like << & >> ans suspect many other C++ programmers like them.
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Thu Oct 14, 2004 9:32 am    Post subject: Re: removal of C++ stream syntax (<< & >>) Reply with quote

Ivan Senji wrote:
kris wrote:
This has been on the cards for a while: what do people think?


No! Don't do it. I really like << & >> ans suspect many other C++ programmers like them.

Good to hear that someone actually uses them Wink

The problem is thus: having to support both approaches simultaneously (get/put; </>>) is becoming a bit unweildly. If we were to select one or the other at compile time, via a version() statement, then there's a real possibility of two library-style projects (using mango.io) clashing in terms of their preferred IO verbs ...

Any ideas on how to do this? One approach would be to relegate one or the other to an adaptor class ...
Back to top
View user's profile Send private message
Ivan Senji



Joined: 03 Sep 2004
Posts: 8
Location: Zagreb, Croatia

PostPosted: Thu Oct 14, 2004 12:18 pm    Post subject: Re: removal of C++ stream syntax (<< & >>) f Reply with quote

kris wrote:
The problem is thus: having to support both approaches simultaneously (get/put; </>>) is becoming a bit unweildly. If we were to select one or the other at compile time, via a version() statement, then there's a real possibility of two library-style projects (using mango.io) clashing in terms of their preferred IO verbs ...


Probabbly this will not help you but i tried:

Code:

class Cout
{
  Cout opShl(int x){...}
  Cout opShl(char[] x){...}
  //...other opShl's
 
  alias opShl put;
}


Trying it the other way around, defining put and aliasing it to opShl crashes the compiler. I don't know if this can scale up to your project's size?
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Thu Oct 14, 2004 12:25 pm    Post subject: Re: removal of C++ stream syntax (<< & >>) Reply with quote

Ivan Senji wrote:
kris wrote:
The problem is thus: having to support both approaches simultaneously (get/put; </>>) is becoming a bit unweildly. If we were to select one or the other at compile time, via a version() statement, then there's a real possibility of two library-style projects (using mango.io) clashing in terms of their preferred IO verbs ...


Probabbly this will not help you but i tried:

Code:

class Cout
{
  Cout opShl(int x){...}
  Cout opShl(char[] x){...}
  //...other opShl's
 
  alias opShl put;
}


Trying it the other way around, defining put and aliasing it to opShl crashes the compiler. I don't know if this can scale up to your project's size?

That's a good alternative to using version(), but has the same problem in terms of potential clashes between author-preferences (through additional mango-based libraries). That is, if author A uses <</>> syntax and author B uses put/get, what happens when author C tries to use code from both A & B at the same time? On the face of it, this would require mango.io to always support both approaches simultaneously, although an adaptor class would potentially resolve that ...

What do you think?
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Thu Oct 14, 2004 3:10 pm    Post subject: Re: removal of C++ stream syntax (<< & >>) Reply with quote

kris wrote:


(snip bit about aliasing opShl() to put() );

That's a good alternative to using version(), but has the same problem in terms of potential clashes between author-preferences (through additional mango-based libraries). That is, if author A uses <</>> syntax and author B uses put/get, what happens when author C tries to use code from both A & B at the same time? On the face of it, this would require mango.io to always support both approaches simultaneously, although an adaptor class would potentially resolve that ...

What do you think?


In a perfect world, the following would be possible:
Code:
class Foo{
   int opShl(int val);
}

version(stdioStyle){
    alias Foo.opShl Foo.put; // breaks here
    int put(Foo this,int val){ return this.opShl(val); } // this doesn't work as a 'pseduo method' like with arrays, but it *is* inline-able.
}


Since we can't do that, I'd opt for keeping both styles onboard at all times. The in-class aliasing technique seems to be the best say to do this.

I honestly can't see any one developer using more than one syntax, but maintaining compilation-level compatibility between libs is probably a better goal than excluding a particular function-style-use ideology. Plus it gets us out of having to track additional versions for the library.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Fri Oct 15, 2004 4:33 am    Post subject: Reply with quote

As long as both methods provide the same functionality; choose one and stick with it (IMHO).
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Fri Oct 15, 2004 10:17 am    Post subject: Reply with quote

larsivi wrote:
As long as both methods provide the same functionality; choose one and stick with it (IMHO).

Just to be clear; I don't think it's so much of an issue over mixing and matching the approach used within the same code body ... rather, it's when one adopts code from multiple third-parties that an issue may arise (if the third parties use alternate syntax). At that point, mango.io is presumeably forced to support both simultaneously, as opposed to one or the other.

One way around this is to make put/get be the de-facto syntax, and provide an optional adapter for exposing the C++ syntax. Another way, of course, is to not change anything Wink

Any other ideas?
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Sun Oct 24, 2004 11:50 pm    Post subject: Reply with quote

The whole Reader/Writer implementation has been replaced, and in a manner which reduces the issue of tracking the <</>> syntax going forward.
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Sun Nov 28, 2004 1:50 pm    Post subject: Reply with quote

Ivan Senji wrote:
Probabbly this will not help you but i tried:

Code:

class Cout
{
  Cout opShl(int x){...}
  Cout opShl(char[] x){...}
  //...other opShl's
 
  alias opShl put;
}

Trying it the other way around, defining put and aliasing it to opShl crashes the compiler. I don't know if this can scale up to your project's size?

The alias approach works well ~ thank you, Ivan Cool
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Mango All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group