On Mon, Sep 15, 2003 at 07:25:01PM -0400, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
contain any number, and that would choose between native integer, native float and Gmp object as suitable for the internal representation.
I don't like the idea of arbitrary (compiler/interpreter decision) conversion between numeric types in case when performance matters.
Ints are faster than floats, but floats are fast enough too, while Gmp objects are extremely slow comparing to both ints/floats.
Actually, even implicit bignums in Pike slow down things significantly - just compare execution time for sscanf("\x80\0\0\0", "%4c", n) and sscanf("\x7f\0\0\0", n) where n is an int - and this is typical operation when IP numbers processing is necessary. Multiply this by millions - you will see the difference.
whole slew of languages that are very similar to Lisp in how types and values are handled.
(programming) languages are tuned for specific tasks. Even Touring computer can do everything, but I don't see anyone who uses this. Same with Lisp - it is good for specific, but not general programming, especially for (former) C programmers (while Pike is promoted as "similar to C/C++").
numeric values: There are many functions that behave completely differently when given a float or an integer, i.e. the type itself is
This is a bad idea by itself - the type of numeric value should not be used as a flag, IMHO - it leads to mistakes for beginners and mystical behavior when arguments are mistyped/mispassed. The function may behave differently if it concerns return value, but if it involves something else - this is EvilThing (r) :)
Not at all. Pike is much more similar to Lisp than it is to C in several fundamental ways.
For instance? Sure you can find a lot of similarity between Pike and Lisp, but this is true for C++ and Lisp as well. Pike is developed as general purpose language (at least now), or?
It seems like you're comparing Pike to strongly typed languages like C, C++ and Java.
Not really. I like the idea of types in general, but I dislike the idea of strict (strongly) types. At least, it would be nice to have pragma or something like that to control this. BTW, what about floats/ints in Java? Is those types so different there as well?
I generally wouldn't want to use a language that's primarily designed to do math, since that's a very small portion of what a typical
True, but it is nice to have a language which is well suited for math too, but still is general purpose. Pike could be the one.
operations is to treat all values and types uniformly. In that regard the numeric equivalences are comparable to those of values and their string representations.
String may represent something that may not be converted (or interpreted) as numeric value, while numeric value may always be represented as string - that's why it makes no sense to blindly (or uniformly) compare strings and numerics.
Two numeric types are also comparable if we won't take precision into account. Actually, the only difference between int and float is exactly the "floating point", managed by exponent part, but this is implementation detail. They both are _numeric_ types - this is important.
Regards, /Al