Topic: About implicit binary operator and user defined


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sun, 02 Feb 2014 14:38:16 +0100
Raw View
This is a multi-part message in MIME format.
--------------030205070309070406060505
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 31/01/14 03:07, Billy O'Neal a =E9crit :
> Is there any reason we really need to make the operator be composed of=20
> symbols?
>
> What about __swap(a, b) ?
>
>
Haskell interpret any 'name' as a binary left associative operator, e.g.

     a 'swap' b;

could mean

     swap(a,b);

Maybe ':' would be more appropriated for C++.

     a :swap: b;

An orthogonal feature could be to be able to define a user operator=20
operator *:symbols:*() (note the symbols are surrounded by two colons)=20
that could allow to define

     A& operator:=3D:(A&x,A&y);
     A& operator:><:(A&x,A&y);

and use it as

     a :=3D: b;
     a :><: b;

What are the pitfalls of such approaches?

Best,
Vicente

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--------------030205070309070406060505
Content-Type: text/html; charset=ISO-8859-1

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Le 31/01/14 03:07, Billy O'Neal a
      &eacute;crit&nbsp;:<br>
    </div>
    <blockquote
cite="mid:CAPBZbvz5HBOFD+zoJ6rDowdxdXL0x4Hbf1wB0jUYO6hqaxC+8Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Is there any reason we really need to make the operator be
          composed of symbols?</div>
        <div><br>
        </div>
        <div>What about __swap(a, b) ?</div>
      </div>
      <div class="gmail_extra"><br>
      </div>
      <br>
    </blockquote>
    Haskell interpret any 'name' as a binary left associative operator,
    e.g. <br>
    <br>
    &nbsp;&nbsp;&nbsp; a 'swap' b; <br>
    <br>
    could mean <br>
    <br>
    &nbsp;&nbsp;&nbsp; swap(a,b);<br>
    <br>
    Maybe ':' would be more appropriated for C++.<br>
    <br>
    &nbsp;&nbsp;&nbsp; a :swap: b; <br>
    <br>
    An orthogonal feature could be to be able to define a user operator
    operator <b>:symbols:</b>() (note the symbols are surrounded by two
    colons) that could allow to define<br>
    <br>
    &nbsp;&nbsp;&nbsp; A&amp; operator:=:(A&amp;x,A&amp;y);<br>
    &nbsp;&nbsp;&nbsp; A&amp; operator:&gt;&lt;:(A&amp;x,A&amp;y);<br>
    <br>
    and use it as<br>
    <br>
    &nbsp;&nbsp;&nbsp; a :=: b; <br>
    &nbsp;&nbsp;&nbsp; a :&gt;&lt;: b; <br>
    <br>
    What are the pitfalls of such approaches?<br>
    <br>
    Best,<br>
    Vicente
  </body>
</html>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

--------------030205070309070406060505--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Sun, 2 Feb 2014 15:55:35 +0200
Raw View
On 2 February 2014 15:38, Vicente J. Botet Escriba
<vicente.botet@wanadoo.fr> wrote:
> Haskell interpret any 'name' as a binary left associative operator, e.g.
>
>     a 'swap' b;
>
> could mean
>
>     swap(a,b);
>
> Maybe ':' would be more appropriated for C++.
>
>     a :swap: b;
>
> An orthogonal feature could be to be able to define a user operator operator
> :symbols:() (note the symbols are surrounded by two colons) that could allow
> to define
>
>     A& operator:=:(A&x,A&y);
>     A& operator:><:(A&x,A&y);
>
> and use it as
>
>     a :=: b;
>     a :><: b;
>
> What are the pitfalls of such approaches?


Operator overloading is supposed to make code more readable. I fail
to see how that would be achieved by a :><: b;, and I don't see
how a 'swap' b; is any more readable than swap(a, b);

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.