ISibboI / evalexpr

A powerful expression evaluation crate 🦀.
GNU Affero General Public License v3.0
325 stars 54 forks source link

Add support for is_nan and other floating-point functions #101

Closed lovasoa closed 2 years ago

lovasoa commented 2 years ago

Add support for is_nan, is_finite, and other floating-point testing functions

ISibboI commented 2 years ago

Thank you, this looks cool. Two things:

lovasoa commented 2 years ago

What purpose does the math:: prefix serve ? is_nan is not really related to math, is it ? Why doesn't round have this prefix ? There is no support for a module system or for namespaces, the math:: prefix seems to just be part of the function name; I'm not sure what its purpose is. I implemented the change anyway... having the function return false on non-float input makes them easier to use, at least in my usecase. I'll switch the behavior to what you suggest, but I'll have to add a new "typeof" function to get the type of a value in order to be able to implement the same behavior in the evalexpr expression itself.

lovasoa commented 2 years ago

@ISibboI : Is there something more you would like me to change before this can be merged ?

ISibboI commented 2 years ago

Thank you very much!

The idea behind putting the functions into modules without having a module system is that we can implement a module system without too large breaking changes.

Having floor, round and ceil as plain functions is likely a mistake.

The typeof function is a good idea!

lovasoa commented 2 years ago

I added the comment you wanted. Does it look ok to you now ?

ISibboI commented 2 years ago

Cool, thanks!

lovasoa commented 2 years ago

Thanks for merging !