Er actually I mean NaN and +/-inf and negation .. as applied go floats :) I seek feedback, opinions, etc ...
/Users/johnskaller/felix/build/release/tut/tutorial/tut-02.02.05-0.flx: line 6, cols 10 to 9 5: | NaN => { print "Not a Number"; } 6: | -inf .. -0.999 => { print "lt -1"; } * 7: | -1.001 .. 1.001 => { print "Unit circle"; } Q1: what to do with NaN // not a legit value +inf // legit xfloat value -inf // legit xfloat value -1.0 // legit float value Denorm Here: float is your ordinary floats (float, double, ldouble). xfloat means floats together with + and - infinity. This is a legitimate number system, but it has different laws of arithmetic. For example 1.0 / 0.0 => +inf in xfloat, but an error in float. Note that Complex usually doesn't allow +/- inf, instead it has plain inf. This makes complex number system complete. NaN is not a floating value as such. It may be considered part of float or xflloat to make 2 new number systems, similar to float_option = | Float of float | NaN i.e. adding an error values .. BUT .. this is NOT how it normally works. In particular NaN != NaN is actually the defining property of NaN (more precisely, NaN != x for any value x, **including** NaN). As such, NaN is not a legitimate value when coupled with the usual way of thinking about equality. We may have isNaN(x) and similarly match x with | NaN => ... make sense. Of course NaN doesn't exist if you have signalling NaNs and signalling is switched on. Grrr .. then we have signalling and non-signalling NaNs .... Denorm is a warning. Denorm values are legit values but they have reduced precision due to the exponent maxing out. Denorm is more of an issue if you switch strict IEEE floating behaviour off. This is useful because it is much faster on some FPUs. Denorm doesn't exist in xfloat because we just switch to +inf or -inf on exponent overflow, and 0.0 on underflow. Finally the easiest one: negative values. Yes, sure, Felix has negative floats! The question is: does it have negative valued literals and the answer at the moment is NO. Not for floats or for integers. Since matches ONLY allow literals, you cannot match on a negative value directly. You have to do this instead: match x with | ?a when a == -1.0 => ... or equivalently match x with | $(-1.0) => .. Unfortunately you cannot do that with ranges: match x with | $(-1.0) .. 1.0 => ... doesn't work now. It used to but now, pattern matching is simplified and generalised to work with ANY literals. Q2: WTF do we do with all the slice notations! In pattens: 1 .. 2 ==> range 1 to 2 inclusive In for loops: for i in 1 upto 2 ==> range 1 to 2 inclusive In string substrings: x.[1 to 2] ==> range 1 to 2 Strings also allow negatives. We also have a slice object in the library. We also have an iterator that works on slices (but is implemented with yield inside a for .. upto .. loop) We seriously need to get rid of this mess! -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language