If I make a program that contains
float x = limit(0, 1, 2);
I will, as expected, get
C:/MinGW/home/Nilsson/Pike/7.7/foo.pike:5:Bad type in assignment. C:/MinGW/home/Nilsson/Pike/7.7/foo.pike:5:Expected: float C:/MinGW/home/Nilsson/Pike/7.7/foo.pike:5:Got : int(1..1)
i.e. the run time type of the limit expression is not compatible with the type of the variable x. If however I change the code to
int x = limit(0.0, 1.0, 2.0);
I will instead get
C:/MinGW/home/Nilsson/Pike/7.7/foo.pike:5:Bad type in assignment. C:/MinGW/home/Nilsson/Pike/7.7/foo.pike:5:Expected: int C:/MinGW/home/Nilsson/Pike/7.7/foo.pike:5:Got : float | float | float
i.e. the compile time type of the limit expression. Why not the run time type?
Not that I know what that limit function is, but what you get there are all compile time types. There are no runtime types at compile time (except when constants are evaluated).
Word choices aside, why is limit constant evaluated with integer arguments, but not with float arguments? Or is it just a trick of light that makes it look that way?
(limit is a recent _math efun by per)
pike-devel@lists.lysator.liu.se