[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Explanation of Octave operator overloading
From: |
John Swensen |
Subject: |
Re: Explanation of Octave operator overloading |
Date: |
Fri, 05 May 2006 09:54:45 -0600 |
User-agent: |
Thunderbird 1.5.0.2 (Windows/20060308) |
John W. Eaton wrote:
> On 5-May-2006, John Swensen wrote:
>
> | Thanks for pointing me in the right direction. That example gave me
> | exactly what I needed. I did find, however, that for simple comparison
> | operations, there are macros to make it *really* easy. The DEFBINOP_OP
> | macro allows you to simply implements an accesor function in the
> | user-defined type to return some integer value that can then be compared
> | against other octave types. In my case, I have a octave_socket class.
> | I used the DEFBINOP_OP macro as follow:
> | DEFBINOP_OP (lt, scalar, scalar, <)
> | DEFBINOP_OP (le, scalar, scalar, <=)
> | DEFBINOP_OP (eq, scalar, scalar, ==)
> | DEFBINOP_OP (ge, scalar, scalar, >=)
> | DEFBINOP_OP (gt, scalar, scalar, >)
> | DEFBINOP_OP (ne, scalar, scalar, !=)
> |
> | I then had to overload the scalar_value() method in my user-defined type
> | and now I can compare against integers with all the operators.
>
> Do you really need to create a new data type for these functions (and
> by "these functions" I mean the normal Unix connect, accept, bind,
> listen, etc.)? Can't you just use an integer for the socket file
> descriptor and a structure for the socket address?
>
> jwe
>
>
>
I could just use an integer. In fact, really the only member variable
is a socket file descriptor. The nice thing, IMO, is the fact that by
defining a new type, sockets get cleaned up nicely when the
octave_socket variable goes out of scope. If you want me to change this
before I submit it for approval, I am willing (and it shouldn't be too
hard). Just let me know if you would prefer me to do it your way.
John Swensen
Re: Explanation of Octave operator overloading, Paul Thomas, 2006/05/06
- Re: Explanation of Octave operator overloading, David Bateman, 2006/05/06
- Re: Explanation of Octave operator overloading, David Bateman, 2006/05/06
- Re: Explanation of Octave operator overloading, Bill Denney, 2006/05/06
- Re: Explanation of Octave operator overloading, John Swensen, 2006/05/09
- Re: Explanation of Octave operator overloading, Paul Thomas, 2006/05/09