On 27 October 2011 20:13, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On 10/26/2011 06:42 PM, Paul Berry wrote:<br>
> In order to implement the GLSL 1.30 isinf() function, it will be<br>
> necessary to be able to represent infinity in the GLSL IR s-expression<br>
> format. This patch extends the s-expression parser so that it treats<br>
> the string "#inf" as a floating point value representing positive<br>
> infinity.<br>
> ---<br>
> src/glsl/s_expression.cpp | 33 +++++++++++++++++++--------------<br>
> 1 files changed, 19 insertions(+), 14 deletions(-)<br>
<br>
</div>Two kind of stupid comments:<br>
<br>
Scheme represents infinity as +inf.0 or -inf.0 and NaN as +nan.0. If<br>
you wanted to be more Scheme-like, you could do that (and also gain a<br>
representation of -infinity if you wanted...)<br>
<br>
Also...strtod() already accepts "INF"/"INFINITY" and "NAN" for these<br>
cases. Which actually kind of sucks because somebody could totally name<br>
their variables that (unlike #inf or +inf.0).<br></blockquote><div><br>Interesting, I wasn't aware of that. According to <a href="http://pubs.opengroup.org/onlinepubs/007904975/functions/strtod.html" target="_blank">http://pubs.opengroup.org/onlinepubs/007904975/functions/strtod.html</a>, "+INFINITY" and "+INF" are also allowed as a representation of infinity; likewise for "+NAN".<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<br>
That should be fixed someday. But there are a lot of things the reader<br>
can't do (like structs), so...not terribly important. It works well<br>
enough for now and we can always fix it when it actually matters.<br></blockquote><div><br>Agreed. In particular, if we ever decide to use the s-expression IR representation to support ARB_get_program_binary, we'll need to fix this. I'll put a comment in the function as a reminder. <br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<br>
So, I guess you've got a few options:<br>
1. Keep patch as is (#inf)<br>
2. Switch to +inf.0, -inf.0, +nan.0 to be like Scheme<br>
3. Drop this patch and just use INFINITY in the built-in files.<br></blockquote><div><br>Ok, I'm now favoring a fourth option:<br><br>4. drop this patch and use "+INF" in the built-in files.<br><br>That has the advantage that it can't be confused with a variable name.<br>
<br>I was going to push the patch series today, but I'm not in any rush. I'll leave it open for another day in case anyone else wants to comment. If no one comments by Monday I'll go with option 4.<br></div>
</div>