Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 31, 2005 about operators | ||||
---|---|---|---|---|
| ||||
I try to learn D by doing stl-like templates. Anyway I have some little problems. 1. I noticed that there is not yet (opApply?) assignment operator, or is there?. 2. Should opCmp work like c's strcmp? 3. i = a[3..4]; // same as i = a.opSlice(3,4); But is there operator for this one: a[3..4]=i; // same as a.opSliceAssing(i,3,4); ??? |
May 31, 2005 Re: about operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant^2i | On Tue, 31 May 2005 11:44:39 +0000 (UTC), Ant^2i wrote: > I try to learn D by doing stl-like templates. Anyway I have some little problems. > > 1. I noticed that there is not yet (opApply?) assignment operator, or is there?. What symbol would be the 'Apply' one? Are you thinking that the '=' (assignment) operator might be overloaded by opApply? > 2. Should opCmp work like c's strcmp? In so far as it is supposed to return '< 0' if the first parameter is less than the second parameter, zero if they are equal value, and '> 0' if the first is greater than the second. > 3. > i = a[3..4]; // same as i = a.opSlice(3,4); > But is there operator for this one: > a[3..4]=i; // same as a.opSliceAssing(i,3,4); ??? I don't think so. -- Derek Parnell Melbourne, Australia 31/05/2005 10:51:53 PM |
May 31, 2005 Re: about operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant^2i | "Ant^2i" <Ant^2i_member@pathlink.com> wrote in message news:d7hin7$1i3h$1@digitaldaemon.com... >I try to learn D by doing stl-like templates. Anyway I have some little > problems. > > 1. I noticed that there is not yet (opApply?) assignment operator, or is there?. It would be called opAssign, the equivalent of operator=() in C++, and no, it can't be overridden. You see, Walter doesn't like implicit casts. |
May 31, 2005 Re: about operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | On Tue, 31 May 2005 18:29:53 -0400, Jarrett Billingsley wrote: > "Ant^2i" <Ant^2i_member@pathlink.com> wrote in message news:d7hin7$1i3h$1@digitaldaemon.com... >>I try to learn D by doing stl-like templates. Anyway I have some little >> problems. >> >> 1. I noticed that there is not yet (opApply?) assignment operator, or is there?. > > It would be called opAssign, the equivalent of operator=() in C++, and no, it can't be overridden. You see, Walter doesn't like implicit casts. Except the ones he's built into the language ;-) -- Derek Melbourne, Australia 1/06/2005 9:28:03 AM |
June 02, 2005 Re: about operators | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant^2i | Ant^2i wrote: > I try to learn D by doing stl-like templates. Anyway I have some little > problems. > > 1. I noticed that there is not yet (opApply?) assignment operator, or is there?. opApply is used to support foreach on a container class. Of course there's an assignment operator. Just no means of overloading it. Partly because Walter doesn't like the idea and partly because the way D works means that it isn't really necessary. http://www.digitalmars.com/d/faq.html#assignmentoverloading > 2. Should opCmp work like c's strcmp? Yes. > 3. i = a[3..4]; // same as i = a.opSlice(3,4); > But is there operator for this one: > a[3..4]=i; // same as a.opSliceAssing(i,3,4); ??? No. Slice assignment isn't currently supported, but when we eventually have it, it should be opSliceAssign. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
Copyright © 1999-2021 by the D Language Foundation