RE: [sv-bc] RE: [sv-ec] overloading an assignment operator

From: Steven Sharp <sharp_at_.....>
Date: Fri Apr 13 2007 - 11:37:11 PDT
>From: "Subhamoy Pal" <spal@Magma-DA.COM>

>What you are saying is just one possibility right? You want += to be
>composed by independent overloading + and =.
>
>But if you check the list of operators can be overloaded, you will see
>+= itself is a valid operator for overloading.

Subhamoy,

I don't know what list you are checking.  I am looking at the list
in the grammar production for overload_operator, in Syntax 8-4 and
A.2.8.  It does not list += as an operator that can be overloaded.

Furthermore, section 8.16 says

"An assignment operator such as += is automatically built from both
the + and = operators successively, where the = has its normal meaning."

So += can end up being built from overloaded operations, but it cannot
be independently overloaded.

The only assignment-like operators that can be overloaded are ++ and --.
This makes sense, because you cannot assume what the representation of
the implicit value 1 would be for any user-defined type.

BTW, my concern about the validity of the assignment overloading between
int and float in the examples you quoted was wrong.  I have been writing
too much C code, and read float as the built-in floating point type.
But in Verilog, that is shortreal.  The float type in the examples is a
user-defined struct type.

Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Apr 13 11:37:31 2007

This archive was generated by hypermail 2.1.8 : Fri Apr 13 2007 - 11:38:43 PDT