It was late... but the penny dropped this morning. Consider the domain of log (x) for x<0.<br><br><div class="gmail_quote">On Thu, May 10, 2012 at 8:38 AM, Vincent St-Amour <span dir="ltr"><<a href="mailto:stamourv@ccs.neu.edu" target="_blank">stamourv@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">As Neil said, `fllog' is guaranteed to return floats.<br>
<br>
If you want to know for which input types `log' has a return type of<br>
`Float', you can use `:query-result-type' at the TR REPL.<br>
<br>
-> (:query-result-type log Float)<br>
(case-> (Nonnegative-Flonum -> Float) (Float-Zero -> Negative-Float))<br>
<br>
If you can't restrict the input type, the solution you mention (adding a<br>
runtime assertion) is perfectly fine, but does involve a check at runtime.<br>
<br>
Vincent<br>
<br>
<br>
At Wed, 9 May 2012 23:52:42 -0400,<br>
Ray Racine wrote:<br>
><br>
> [1 <multipart/alternative (7bit)>]<br>
> [1.1 <text/plain; ISO-8859-1 (7bit)>]<br>
<div><div class="h5">> The Typed Racket Performance button in DrRacket informs me that (log v)<br>
> returns a Complex type, despite all its arguments being reals and that if I<br>
> do not want or expect a complex number as results, I mam restrict the type<br>
> of the arguments. How does one do that?<br>
><br>
> #lang typed/racket/base<br>
><br>
> (: real-log (Float -> Float))<br>
> (define (real-log v)<br>
> (assert (log v) flonum?))<br>
</div></div>> [1.2 <text/html; ISO-8859-1 (quoted-printable)>]<br>
><br>
> [2 <text/plain; us-ascii (7bit)>]<br>
<div class="HOEnZb"><div class="h5">> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br>