Be warned there's a nasty bug here: This works: typedef fun pred (T:TYPE):TYPE => typematch T with | 7 => 6 | 6 => 5 | 5 => 4 | 4 => 3 | 3 => 2 | 2 => 1 | 1 => 0 endmatch;
class Trick2[T] { virtual fun rank : 1 -> int; } instance [N] Trick2[N] { fun rank() => memcount[N].int + Trick2[pred N]::rank (); } instance Trick2 [1] { fun rank() => 1; } println$ "by instance " + str #Trick2[4]::rank; however this doesn't: fun rank() => memcount[N] + Trick2[pred N]::rank (); The error message is misleading: /felix>flx --test=build/release rank Flx_egen: Waring: delayed virtual instantiation, external fun rank<30953> CLIENT ERROR Instantiate virtual function(2) rank<30953>, no instance for ts=4 Instances are unit->unit In /Users/johnskaller/felix/build/release/lib/std/io/textio.flx: line 138, cols 76 to 71 137: proc writeln : ostream * string ="::flx::rtl::ioutil::writeln($1,$2);"; 138: proc write : ostream * string ="::flx::rtl::ioutil::write($1,$2);"; * 139: proc write : ostream * utiny ="$1->put($2);"; See also /Users/johnskaller/felix/./rank.flx: line 45, cols 18 to 30 44: class Trick2[T] { 45: virtual fun rank : 1 -> int; ************* 46: } In fact, memcount[] is of type size, which can be added to an int to give type size, so the rank() function returns type size, therefore it isn't an "override" or instance of the virtual rank. I personally didn't realise the whole type had to match, not just the signature: I'd have expected if the signature matched and the return type didn't I get a binding error. So be warned. This is not a bug, but it is misleading. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language