View previous topic :: View next topic |
Author |
Message |
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Wed Oct 13, 2004 7:51 pm Post subject: removal of C++ stream syntax (<< & >>) ? |
|
|
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 |
|
|
Ivan Senji
Joined: 03 Sep 2004 Posts: 8 Location: Zagreb, Croatia
|
Posted: Thu Oct 14, 2004 7:51 am Post subject: Re: removal of C++ stream syntax (<< & >>) f |
|
|
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 |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Thu Oct 14, 2004 9:32 am Post subject: Re: removal of C++ stream syntax (<< & >>) |
|
|
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
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 |
|
|
Ivan Senji
Joined: 03 Sep 2004 Posts: 8 Location: Zagreb, Croatia
|
Posted: Thu Oct 14, 2004 12:18 pm Post subject: Re: removal of C++ stream syntax (<< & >>) f |
|
|
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 |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Thu Oct 14, 2004 12:25 pm Post subject: Re: removal of C++ stream syntax (<< & >>) |
|
|
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 |
|
|
pragma
Joined: 28 May 2004 Posts: 607 Location: Washington, DC
|
Posted: Thu Oct 14, 2004 3:10 pm Post subject: Re: removal of C++ stream syntax (<< & >>) |
|
|
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 |
|
|
larsivi Site Admin
Joined: 27 Mar 2004 Posts: 453 Location: Trondheim, Norway
|
Posted: Fri Oct 15, 2004 4:33 am Post subject: |
|
|
As long as both methods provide the same functionality; choose one and stick with it (IMHO). |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Fri Oct 15, 2004 10:17 am Post subject: |
|
|
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
Any other ideas? |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sun Oct 24, 2004 11:50 pm Post subject: |
|
|
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 |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sun Nov 28, 2004 1:50 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
|