Re: [sv-bc] Issue 41 - real in associative array

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Fri Apr 24 2009 - 10:44:23 PDT
Jonathan, I completely agree with your point but
not necessarily the conclusion.  Anyone desiring
to do what you are doing below would recode the
example using something valid (a list of reals
for example) and then use "==" and get into the
same fundamental problem.  Alternatively, they
might just do $realtobits and use an associative
array on the bit vectors (with the same issue again).

Users can hurt themselves with reals --
if they care, I'd expect a user to create a
"tolerance function" to normalize reals into
representative values within some tolerance range
and operate on those values.  I don't see much
point in arbitrarily restricting associative
arrays of real in order to try to protect the user.

Gord.


jonathan.bromley@doulos.com wrote:
>> I took a closer look at issue 41.  The LRM certainly does
>> intentionally restrict the existence of "real" in any
>> component of an associative array index type.  This is a
>> bit odd since the general statement is simply that equality
>> (and some internal ordering relation) is defined and certainly
>> equality is defined for real.  Personally I think that it makes
>> more sense to drop the restriction than to modify the example
>> but if there is any concern about dropping the restriction,
>> then we should modify the example to be consistent with the
>> normative text.
> 
> Gord is clearly right to say that equality is defined for 
> reals, in the sense that there is an equality comparison
> operator and it does something vaguely useful.  However,
> I am (as a matter of principle) uncomfortable about
> any attempt to use reals to model or represent discrete
> values; indeed, I would always regard testing reals for
> equality as being fragile and untrustworthy.  You just 
> KNOW that someone will complain when this doesn't do 
> what they expect:
> 
>   real thirty_degrees = $atan(1.0) * 2.0 / 3.0;
>   bit visited[real];
>   visited[thirty_degrees] = 1;
>   assert (visited[$asin(0.5)]);
> 
> So I would prefer to see the ballot feedback implemented
> as-is by modifying the example to avoid the use of real.

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Apr 24 10:46:06 2009

This archive was generated by hypermail 2.1.8 : Fri Apr 24 2009 - 10:46:49 PDT