On Sun, 09 Oct 2011 10:59:29 -0400, Leon Timmermans <faw...@gmail.com> wrote:

Do you really want your end users to think of IP addresses as numbers?

Yes. They are numbers that translate to and from strings in new ways. I want my end users to say "This is a number. I can add to it, subtract from it, bitshift it, and sort arrays of it. I can also stringify it in a way that makes human sense".

You're confusing implementation and interface. I'm not saying bigints
are a wrong implementation for this, I'm saying you shouldn't expose
that to your end users. Precisely because almost all numeric
operations do not make sense on an IP address.

What's really key is that I want to expose the choice of which BigInt backend to use to my end users. Different implementations perform differently on different systems, so they should be free to benchmark and choose what works best for their situation. It's the old adage ... "when faced with two or more conflicting ways to do something, let the user choose".

Also, exposing the overloaded operators for the useful operations is a huge plus (pardon the pun). I don't care if I can't currently imagine a situation where dividing one IP address by another is a good idea, it's an idea that someone might have. I suppose I might be advised to overload the overload on those operations, but why arbitrarily and stubbornly limit the user? Maybe overload the overload to throw a warning, but that's only going to train the users to ignore other (potentially warnings) from my package.



--
Paul Bennett (PWBENNETT)

Reply via email to