Thread overview | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 08, 2004 Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
I would like to propose a possibility to over(?)load operators "!","#","?","$" (both - unary and binary) Thanx Yan |
February 08, 2004 Re: Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yan | To do what? Please provide examples of what you intend, so we can give you opinions "Yan" <Yan_member@pathlink.com> wrote in message news:c0695d$2b15$1@digitaldaemon.com... > I would like to propose a possibility to > over(?)load operators "!","#","?","$" (both - unary and binary) > Thanx > Yan > > |
February 09, 2004 Re: Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yan | >I would like to propose a possibility to
>over(?)load operators "!","#","?","$" (both - unary and binary)
Hey, that's unfair! Why $ but not €?
|
February 09, 2004 Re: Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthias Becker | and what about £ ? and then we have °, and § and ¬ and ¦ and ¢ and ¨ ? :D "Matthias Becker" <Matthias_member@pathlink.com> schrieb im Newsbeitrag news:c07skh$1uhc$1@digitaldaemon.com... > >I would like to propose a possibility to > >over(?)load operators "!","#","?","$" (both - unary and binary) > > Hey, that's unfair! Why $ but not €? > > |
February 09, 2004 Re: Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | for more amusement along these lines check out http://www.research.att.com/~bs/whitespace98.pdf "davepermen" <davepermen@hotmail.com> wrote in message news:c07srf$1uut$1@digitaldaemon.com... | and what about £ ? | | and then we have °, and § and ¬ and ¦ and ¢ and ¨ ? | | :D | | "Matthias Becker" <Matthias_member@pathlink.com> schrieb im Newsbeitrag | news:c07skh$1uhc$1@digitaldaemon.com... | > >I would like to propose a possibility to | > >over(?)load operators "!","#","?","$" (both - unary and binary) | > | > Hey, that's unfair! Why $ but not ?? | > | > | | |
February 09, 2004 Re: Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | i know that yet.. what about the one with the \\ comments? :D here is the comment \\ x = 10; :D "Ben Hinkle" <bhinkle4@juno.com> schrieb im Newsbeitrag news:c0846h$2b01$1@digitaldaemon.com... > for more amusement along these lines check out http://www.research.att.com/~bs/whitespace98.pdf > > "davepermen" <davepermen@hotmail.com> wrote in message > news:c07srf$1uut$1@digitaldaemon.com... > | and what about £ ? > | > | and then we have °, and § and ¬ and ¦ and ¢ and ¨ ? > | > | :D > | > | "Matthias Becker" <Matthias_member@pathlink.com> schrieb im Newsbeitrag > | news:c07skh$1uhc$1@digitaldaemon.com... > | > >I would like to propose a possibility to > | > >over(?)load operators "!","#","?","$" (both - unary and binary) > | > > | > Hey, that's unfair! Why $ but not ?? > | > > | > > | > | > > |
February 09, 2004 Re: Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | If we have more complicated objects than ints and reals and bools (for example - vectors, armies, rockets, planets...), then we would have more possible operations on them. Some of such operations will be used frequently. Remember scalar and cross products of vectors. You could overload "*" operator to get scalar product. Why not to overload "@" operator in order to get cross product? Or i must use "%" or "~" only? We find in specification "Since ++e is defined to be semantically equivalent to (e += 1), the expression ++e is rewritten as (e += 1), and then checking for operator overloading is done. The situation is analogous for --e". But who says that e is such an object that operation ++ is comutative? Example: Army a1 = new Army(); a1++; // to add 1 soldier on the right flank ++a1; // to add 1 soldier on the left flank In article <c06f1p$2kkr$2@digitaldaemon.com>, Matthew says... > >To do what? > >Please provide examples of what you intend, so we can give you opinions > >"Yan" <Yan_member@pathlink.com> wrote in message news:c0695d$2b15$1@digitaldaemon.com... >> I would like to propose a possibility to >> over(?)load operators "!","#","?","$" (both - unary and binary) >> Thanx >> Yan >> >> > > |
February 09, 2004 Re: Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to mosfox | mosfox@yandex.ru wrote: > If we have more complicated objects than ints and reals and bools > (for example - vectors, armies, rockets, planets...), then we would have more > possible operations on them. Some of such operations will be used > frequently. Remember scalar and cross products of vectors. > You could overload "*" operator to get scalar product. > Why not to overload "@" operator in order to get cross product? > Or i must use "%" or "~" only? How about a method called 'dot'? :) > We find in specification > "Since ++e is defined to be semantically equivalent to (e += 1), the > expression ++e is rewritten as (e += 1), and then checking for operator > overloading is done. The situation is analogous for --e". > But who says that e is such an object that operation ++ is comutative? > > Example: > > Army a1 = new Army(); > a1++; // to add 1 soldier on the right flank > ++a1; // to add 1 soldier on the left flank eeeeek. -- andy |
February 09, 2004 Re: Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | In article <c08aj5$2l2v$1@digitaldaemon.com>, Andy Friesen says... > >mosfox@yandex.ru wrote: >> If we have more complicated objects than ints and reals and bools >> (for example - vectors, armies, rockets, planets...), then we would have more >> possible operations on them. Some of such operations will be used >> frequently. Remember scalar and cross products of vectors. >> You could overload "*" operator to get scalar product. >> Why not to overload "@" operator in order to get cross product? >> Or i must use "%" or "~" only? > >How about a method called 'dot'? :) dot(dot(dot(dot(a,dot(b,dot(c,d))),e),f),g) ... %-/ ..OR... ((a@(b@(c@d))@e)@f)@g > >> We find in specification >> "Since ++e is defined to be semantically equivalent to (e += 1), the >> expression ++e is rewritten as (e += 1), and then checking for operator >> overloading is done. The situation is analogous for --e". >> But who says that e is such an object that operation ++ is comutative? >> >> Example: >> >> Army a1 = new Army(); >> a1++; // to add 1 soldier on the right flank >> ++a1; // to add 1 soldier on the left flank > >eeeeek. > > -- andy |
February 09, 2004 Re: Proposal: overloading of ! and # and $ etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to mosfox | <snip> > You could overload "*" operator to get scalar product. > Why not to overload "@" operator in order to get cross product? > Or i must use "%" or "~" only? > FWIW I think it would be a mistake to add more ASCII characters as operators. UNICODE provides a rich set of mathematical symbols which are available for use. To create a dot product operator, the unicode symbol for "DOT" (unicode 22C5) should be used. To create a cross product operator, the UNICODE symbol for "CROSS PRODUCT" (unicode 00D7) should be used. This is what I had in mind when I posted the following: http://www.digitalmars.com/drn-bin/wwwnews?D/19736 Also, IMO overloaded operators should not be used unless they have a clear meaning in mathmatics and make code easier to read. Mark. <snip> |
Copyright © 1999-2021 by the D Language Foundation