August 19, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan Andrew | "Jonathan Andrew" <jon@ece.arizona.edu> wrote in message news:3D611674.3D0C2921@ece.arizona.edu... > I don't think it gets much simpler than that. I agree with anderson, good job! Thanks! I've sinced added a blurb to www.digitalmars.com/d/cpptod.html to highlight the difference between the D way and the C++ way. |
August 19, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:ajr7iv$1ddn$1@digitaldaemon.com... > What happened to the nice Vector operator (Vector a) + (Vector b) {} syntax > everyone was voting for? I believe that adds significant complexity to the language, whereas the naming convention route offers equivalent power (or even more power, as the functions can be virtual, variadic, etc.) very simply. > You figured out a way around the friend problem. Yes, that one had me stumped for a while. > Some things just don't properly belong in either class and should be sorta global. I agree, but since the desired result can be adequately addressed with the member syntax, I thought adding more syntax for global functions was not worth the cost. |
August 19, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joe Battelle | "Joe Battelle" <Joe_member@pathlink.com> wrote in message news:ajr888$1eqp$1@digitaldaemon.com... > "where a is a class or struct object reference..." > Did I miss something or are we getting concrete types (in C++ parlance) as well? > All the examples show class and not struct so--maybe not yet? The struct overloading is implemented. |
August 19, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | >The struct overloading is implemented.
Just for operator members or have you added methods to structs in the general case?
|
August 19, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joe Battelle | On Mon, 19 Aug 2002 18:19:03 +0000 (UTC) Joe Battelle <Joe_member@pathlink.com> wrote:
> Just for operator members or have you added methods to structs in the general case?
They were added loooong ago.
|
August 19, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | On Sun, 18 Aug 2002 23:53:48 -0700 "Walter" <walter@digitalmars.com> wrote:
> ftp://www.digitalmars.com/dmdalpha.zip
>
> www.digitalmars.com/d/operatoroverloading.html
>
> It doesn't do all the operators yet, but it's a start.
Great. Not the syntax I was expecting, frankly, but hey - it works, and does its job well! Now, as soon as we get all operators (by the way, will binary ~ and ~= be supported? I hope so!), only templates would be left of important C++ functionality not covered by D...
By the way... I proposed this once before, but back then, operator
overloading wasn't implemented. What about input and output operators,
for example -> and <-, to use them for streams and alike where
C++ overloads >> and <<. They wouldn't be allowed on global types,
so you'd have to overload them. But it could be useful:
int main()
{
char[] name;
cout <- "Enter your name: ";
cin -> name;
cout <- "Hello, " <- name <- "!\n";
return 0;
}
Well, you get the idea. It could also be some other operator, maybe one of these: @> #> $> :> or something else. I don't care really, it would be just great if there was some better way to output data then printf().
|
August 19, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | >They were added loooong ago.
Sorry about that, I kept reading this line from the Structs documentation: "Member functions and static members are allowed." as though it had a _not_ in it. Weird, there's a not right above it--maybe my brain grabbed on to that one :)
|
August 19, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374879772193056@news.digitalmars.com... >Great. Not the syntax I was expecting, frankly, but hey - it works, and does its job well! Now, as soon as we get all operators (by the way, will binary ~ and ~= be supported? I hope so!), Yes, I just forgot them for the moment. >only templates would be left of important C++ functionality not covered by D... With a much simpler language! >By the way... I proposed this once before, but back then, operator overloading wasn't implemented. What about input and output operators, for example -> and <-, to use them for streams and alike where C++ overloads >> and <<. They wouldn't be allowed on global types, so you'd have to overload them. But it could be useful: I confess I just never liked the idea behind iostreams and the overloaded operators for it. It just never looked right or elegant. It also always seemed to result in fat exe's. |
August 20, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | It'll do. ;) Now if I can just get a windows.d that has GetFocus() and PeekMessage() in it... I'll be in business! Sean "Walter" <walter@digitalmars.com> wrote in message news:ajrat2$1kdf$1@digitaldaemon.com... > > "Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:ajr7iv$1ddn$1@digitaldaemon.com... > > What happened to the nice Vector operator (Vector a) + (Vector b) {} > syntax > > everyone was voting for? > > I believe that adds significant complexity to the language, whereas the naming convention route offers equivalent power (or even more power, as the > functions can be virtual, variadic, etc.) very simply. > > > You figured out a way around the friend problem. > > Yes, that one had me stumped for a while. > > > Some things just don't properly belong in either class and should be sorta > > global. > > I agree, but since the desired result can be adequately addressed with the member syntax, I thought adding more syntax for global functions was not worth the cost. |
August 20, 2002 Re: dmd 0.37 release - operator overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:ajsoge$7sn$1@digitaldaemon.com... > Now if I can just get a windows.d that has GetFocus() and PeekMessage() in > it... I'll be in business! ok, ok! |
Copyright © 1999-2021 by the D Language Foundation