aardvark-platform / aardvark.base

Aardvark.Base is the foundation of the open-source Aardvark Platform for visual computing, real-time graphics, and visualization.
https://aardvarkians.com/
Apache License 2.0
154 stars 9 forks source link

Equals #43

Closed krauthaufen closed 4 years ago

krauthaufen commented 4 years ago

We recently introduced a lot of boxing/unboxing/type-tests in https://github.com/aardvark-platform/aardvark.base/commit/d28b601cca83046ef08452409dea6f5f3fb238c5 which should be resolved by adding concrete Equals overloads for primitive types in my opinion... Thoughts?

luithefirst commented 4 years ago

Whats the reason to use Equals instead of == on basic value types like float and double?

Why not use the == operator for our primitives? From my point using the operator is more convenient and natural.

krauthaufen commented 4 years ago

the actual reason is that double.NaN.Equals(double.NaN) => true but double.NaN == double.NaN => false

luithefirst commented 4 years ago

Right... for a moment I had something like this in mind. This important information is completely missing here: https://docs.microsoft.com/en-us/dotnet/api/system.single.equals?view=netframework-4.8 Yes, I would assume in most cases it makes more sense to treat NaN as "Equal", like when you put a Ray in a dictionary.

For reasons to make the code more pleasing in the Equal methods, using Equals is reasonable. We definitely need to avoid boxing/unboxing and AggressiveInline most of them.

hyazinthh commented 4 years ago

Resolved in https://github.com/aardvark-platform/aardvark.base/commit/ae8de74e8844669e4024e031bf245d8fef96f82d

krauthaufen commented 4 years ago

Nice!