I meant for the purpose of overloading, the '=' assignment is considered a unary operator, like unary +. Also, section 8.16 considers += as two independent operators, even though it's considered a binary operator elsewhere. Calling this feature operator overloading is a misnomer. It's really function binding for undefined operators; a requirement that came from synthesis, not OOP. I'm assuming that it would be an error to specify the incorrect number of arguments for the operator you are binding to. Dave ________________________________ From: Subhamoy Pal [mailto:spal@Magma-DA.COM] Sent: Thursday, April 12, 2007 11:16 AM To: Rich, Dave; Steven Sharp; sv-ec@eda-stds.org; sv-bc@eda-stds.org Subject: RE: [sv-bc] RE: [sv-ec] overloading an assignment operator Hi Dave, Back to my original queries I will like to ask you something. You said, "The LRM considers assignment a unary operator". Can you please point me any LRM verse to support this? I really did not find assignment operator either in unary operators' list or in binary operators' list. Else we can think LRM is not clear about this. In C++ and C, assignment operator is binary operator, based on which SV defines assignment operators such as "+=", ">>>=" etc. Second query is does LRM pose any restriction on the no of arguments of the bounded function for unary or binary operator? It does not. So I can bind a function with 2 arguments to a unary operator or can bound a function with 1 argument to a unary operator. Here also I just like to mention C, C++ explicitly specifies the no of arguments to have a function when to use it for overloading an operator. Thanks, Subhamoy ________________________________ From: Rich, Dave [mailto:Dave_Rich@mentor.com] Sent: Thursday, April 12, 2007 11:24 PM To: Subhamoy Pal; Steven Sharp; sv-ec@eda-stds.org; sv-bc@eda-stds.org Subject: RE: [sv-bc] RE: [sv-ec] overloading an assignment operator Subhamoy, It looks like you've answered your own question. The LRM considers assignment a unary operator. So the statement out1 = (temp = in); is really two unary assignments. The first is an assignment from an int to complex. The second assignment is the result of the previous assignment, which is a complex type, to another complex type. So you can only overload the assignment from int to complex, since complex to complex is already defined. That overloading function would look like: function complex assgn(int i); assgn.Real = i; assgn.imaginary = 0; endfunction ________________________________ From: owner-sv-bc@server.eda.org [mailto:owner-sv-bc@server.eda.org] On Behalf Of Subhamoy Pal Sent: Thursday, April 12, 2007 10:34 AM To: Steven Sharp; sv-ec@server.eda-stds.org; sv-bc@server.eda-stds.org Subject: [sv-bc] RE: [sv-ec] overloading an assignment operator Hi Steven, SV LRM 8.16 has these lines. ================ Overloading the assignment operator also serves to overload implicit assignments or casting. Here these are using the same functions as the unary +. bind = function float fcopyi(int); // cast int to float bind = function float fcopyr(real); // cast real to float bind = function float fcopyr(shortreal); // cast shortreal to float So it means LRM gives provision for overloading assignment. Thank, Subhamoy -----Original Message----- From: Steven Sharp [mailto:sharp@cadence.com] Sent: Thursday, April 12, 2007 10:55 PM To: sv-ec@eda-stds.org; sv-bc@eda-stds.org; Subhamoy Pal Subject: Re: [sv-ec] overloading an assignment operator The LRM lists the operators that can be overloaded, and it does not include assignment. There is other text that indicates that this was not an oversight. The LRM only allows overloading of operators when applied to data types that would otherwise be illegal for them. Assignment is legal for all data types. The LRM also explicitly talks about arithmetic operators, which does not include assignment. So it seems quite clear that an assignment operator cannot be overloaded. Steven Sharp sharp@cadence.com -- This message has been scanned for viruses and dangerous content by MailScanner <http://www.mailscanner.info/> , and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Thu Apr 12 11:55:15 2007
This archive was generated by hypermail 2.1.8 : Thu Apr 12 2007 - 11:55:28 PDT