On Sun, 2007-08-26 at 11:13 +1000, skaller wrote: > On Sat, 2007-08-25 at 17:12 -0700, Erick Tryzelaar wrote:
> If you know the list on the RHS of the -> symbol is non-empty, > then you can probably do this with a typematch .. something like: > > typematch typeof (list (1,2,3)) with > | list [?t] => ?t > endmatch > > > looks like it should work .. but probably doesn't. Well I'll be ..... ///////////////////////////////////////// #import <flx.flxh> open List; val a = list(1,2,3); var b : typematch typeof(a) with | list[?t] => t endmatch = 1 ; println b; /////////////////////////////////////////// Note I HAD to use a 'val' for a. The type of x in var x = 1; is actually lvalue[int] and not just int, so the typematch fails. Might be worth a no_lvalues_please_typeof (x) operator .. with a wrong type you get some message like: SYSTEM FAILURE beta-reduce failed in lvalue[(typematch lvalue[(int<1815> -> int<1815>)] with | <T5403> -> <T5402> => <T5402> endmatch)]msg: [beta-reduce] typematch failure where you would REALLY like: the message to say "The type of x must be a list, got blah instead" -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language