Oops, you are right. Assignment *is* listed in the overload_operator production. It looked to me like a ==, since it was after the other comparison operators. Sorry about that. But this means that there is a contradiction in the LRM. It explicitly says that it does not change the meaning of the operators for those data types where it is legal to apply them. So you could claim that it works for assignments where there is no legal implicit cast between the two types, and provides an explicit cast. But the example you give includes assignments between integer and floating point types. Those already have implicit casts defined, and are perfectly legal. There are also inherent problems with any kind of overloading that depends on the exact type of any integral expression. Verilog does so much implicit conversion in integral expressions that I don't see any way to determine the exact type of any integral expression. This is presumably why overloading is only allowed for other types, such as unpacked structs. So I guess we must conclude that overloading of assignment is legal, but only to provide a cast between two types that are not assignment compatible (and while it doesn't say so, neither type should be an integral type, due to the impossibility of determining such types in general, unless all integral types are considered equivalent for this purpose). And then we must conclude that the examples of assignment overloading are wrong, since the types involved are assignment compatible. So getting back to your original question... Someone else might be able to respond more authoritatively, but here is how it looks to me. No, I don't think assignment would be a binary operator. It is essentially providing a cast, not the assignment itself. You would not have a function with an input and output argument, that assigns the input to the output. Instead, you have a function that takes the RHS as an input argument, and returns a value of the LHS type, which is then assigned to the LHS. So it is a unary operator. The examples seem to support this, despite their other problems. 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 Thu Apr 12 10:59:22 2007
This archive was generated by hypermail 2.1.8 : Thu Apr 12 2007 - 10:59:46 PDT