Jump to page: 1 2
Thread overview
Proposal: overloading of ! and # and $ etc.
Feb 08, 2004
Yan
Feb 08, 2004
Matthew
Feb 09, 2004
mosfox
Feb 09, 2004
Andy Friesen
Feb 09, 2004
Yan
Feb 10, 2004
Andy Friesen
Feb 10, 2004
J Anderson
Feb 10, 2004
Andy Friesen
Feb 09, 2004
Mark J. Brudnak
Feb 09, 2004
davepermen
Feb 09, 2004
Matthew
Feb 09, 2004
Matthias Becker
Feb 09, 2004
davepermen
Feb 09, 2004
Ben Hinkle
Feb 09, 2004
davepermen
February 08, 2004
I would like to propose a possibility to
over(?)load operators "!","#","?","$" (both - unary and binary)
Thanx
Yan


February 08, 2004
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
>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
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
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
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
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
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
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
<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>


« First   ‹ Prev
1 2