skaller wrote:
> you're trying to divide a string by a long double .. :)
Thats felix's fault, not mine :) If you replace the ldoubles with
doubles in the example, it now works. Felix just doesn't like the
ldouble "L" suffix:
##############################
#import <flx.flxh>
typeclass Show2[T] {
virtual fun str2: T -> string;
}
gen vsprintf[t]: string * t -> string =
"flx::rtl::strutil::flx_asprintf(const_cast<char*>($1.c_str()),$T2)"
requires flx_strutil;
fun format_real (t:double, precision:int) : string = {
var format = f"%%.%ig" precision;
val s = vsprintf (format, t);
return s;
}
instance Show2[double] {
fun str2 (t:double) : string => format_real (t, 12);
}
open Show2[double];
proc p[T with Show2[T]] (t:T) {
print $ "str: " + (str2 t); endl;
}
p (1.0 / 1.0);
##############################
prints:
str: 1
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language