On Fri, 2007-04-27 at 19:42 -0700, Erick Tryzelaar wrote:
> So it looks these values are matchable, but they aren't defined so that
> you can do "print inf; endl". Can we still match against a NaN or an inf
> if we replace these with typeclass functions?
Don't know: we should review for 1.1.4. It doesn't make
sense to compare NaN, NaN isn't actually a value.
So matching a NaN is quite different from printing
a value which matches NaN: print NaN should not work.
However +/- inf are perfectly valid values, so print inf
should work. Or perhaps:
fun apply_inf: 1 -> double = "1.0/0.0";
print$ inf();
should work. Or perhaps:
const inf: double = "1.0/0.0";
There is a difference between a constructor
and a function or value, which is quite confusing.
For example in Cons (x,y), Cons is used as a function,
and in pattern | Cons (?x, ?y) => ... it is used
as the inverse (partial) function.
For argumentless constructors the distinction is harder to see:
union X = | A; // or just enum X { A };
A is still a 'function' which can construct a value of X,
and also an inverse function which can destruct an X
(and which returns no value).
So, NaN is NOT a constructor: it's a destructor only.
OTOH inf is a regular constructor, in fact 1.2 is a
similar constructor .. both can (should be able to)
create a double value and be used to match against it.
> I could see it useful to be able to have a numeric_limits-like typeclass
> to provide this kind of metadata about types.
C++ numeric limits are singularly useless because they can't
be accessed during pre-processing .. which is where they're
usually needed. C macros don't have this problem .. and
are available at run time too.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language