POV-Ray : Newsgroups : povray.unofficial.patches : My personal wishlist : Re: My personal wishlist Server Time
2 Sep 2024 20:14:06 EDT (-0400)
  Re: My personal wishlist  
From: Thorsten Froehlich
Date: 26 Feb 2000 20:02:24
Message: <38b877a0@news.povray.org>
In article <O1+4OE0dCXqQafXKqfXLL1aqGEUo@4ax.com> , Peter Popov 
<pet### [at] usanet>  wrote:

>>Therefore, I would probably just add integer types (maybe char, but most
>>likely not).  And I'm pretty sure I'd totally avoid any unsigned types.
>
> These should suffice, really. And at first I didn't realize the
> problems a person with no programming background might run into when
> working with unsigned types. You're right, leave'em out.

When using only integer types, I think the whole thing can be hidden from
the user and POV-Ray automatically determines the type (floating-point or
integer). This allows for hiding the type from the user, and in loop, etc
even new users would get the benefit without ever having to deal with
variable types.

For a #declare (of a so far undefined variable) just check if the value is
an integer and then store it as such.  I.e. "#declare MyFoo = 1" is an
integer, but neither would be "#declare MyFoo = 1.0" or "#declare MyFoo =
1.8542".  Now, whenever a floating-point result is to be assigned to this
integer, promote "MyFoo" to floating-point (for backward compatibility!).

User control can still be available, i.e. introducing two functions to
eliminate the common operations that should create floating-point results:
For division offer a Pascal style "div" function (or even operator), and to
still allow mixing integer and floating-point math without forcing promotion
to floating-point for the result, an "int" function which can be placed
around any section of a function, for example "#declare MyFoo = 1; #declare
MyFoo = 8084 div 7 + MyFoo - (int(sin(45) * 10) * MyFoo;" would still give
in an integer result.

During evaluation this should still be possible with (nearly?) no runtime
penalty.


     Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.