OK, I think I see now... let me see if I'm right :) One way to do it would be to allow the type-conversion "M (Integer'(-1))" to wrap-around in the same way as all other operations on a modular type do. The argument I see in the appendix to AI-00340 is that type conversion is sometimes "lossy" in other areas (eg real->integer), so why not here too. The other option (which is what was implemented in Ada as I understand it) was to add an attribute to the modular type to allow a "different-sort-of-type-conversion". Does that covert it? Thanks, Martin -----Original Message----- From: owner-vhdl-200x@eda.org [mailto:owner-vhdl-200x@eda.org] On Behalf Of tgingold@free.fr Sent: 26 June 2014 18:06 To: vhdl-200x@eda.org Subject: Re: [vhdl-200x] Modular types > Thanks Tristan - I noticed this behaviour but forgot to comment on it. > For other interested parties, the relevant bit of the LRM is: [...] > Now, I can see the reasoning - without an explicit type-conversion > (using 'mod), it's more in the VHDL-like "fail as early as possible" > mindset. But perhaps without an explicit type-conversion you > shouldn't be allowed to assign an integer to a modular type, so it > should fail at compile-time? Ada is strongly typed as VHDL, so you cannot assign a signed integer to a modular integer without an explicit type-conversion. So indeed, such direct assignment is rejected at compile time. > I imagine you've written rather more Ada code than I have, so could > you elucidate a bit more on the problems the current Ada Behaviour > causes please? You mention it is "error-prone". What would your > preferred behaviour be - to fail at compile-time, or treat all > assignments as asking for a "wraparound", or something else entirely? The issue is the behaviour of the type-conversion. When you use modular type (in Ada), you think that all operations wraps-around. That's true except for type conversion. If M is a modular type, M (Integer'(-1)) raise an error instead of returning M'Modulus - 1. I think this was a mistake (and I am not alone, see AI-00340 for opinions). Regards, Tristan. -- This message has been scanned for viruses and dangerous content by MailScanner, 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 Fri Jun 27 00:36:41 2014
This archive was generated by hypermail 2.1.8 : Fri Jun 27 2014 - 00:37:12 PDT