Did you get a chance to look at this one?
Erick Tryzelaar wrote:
> This:
>
> #######################################################
> #import <flx.flxh>
>
> 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 with Real[T]] (t:T, precision:int) : string = {
> var format = f"%%.%ig" precision;
> val s:string = vsprintf (format, t);
> return
> regmatch s with
> | ["0" - "9"]+ => s + ".0"
> | _ => s
> endmatch
> ;
> }
>
> print $ format_real (1.0, 12); endl;
> #######################################################
>
> errors out with:
>
> [flx_generic:make_varmap] vs/ts mismatch vs=T; ts =
> UNRESOLVED RETURN ERROR
> In foo2.flx: line 9 col 5 to line 12 col 12
> 8: return
> 9: regmatch s with
> 10: | ["0" - "9"]+ => s + ".0"
> 11: | _ => s
> 12: endmatch
> 13: ;
>
> [typeofindex'] function format_real_mh1009<1012>: Can't resolve return
> type, got : <T1012>
> Possibly each returned expression depends on the return type
> Try adding an explicit return type annotation
>
>
> Then, if I lift it out, it gets another error:
>
> #######################################################
> #import <flx.flxh>
>
> gen vsprintf[t]: string * t -> string =
> "flx::rtl::strutil::flx_asprintf(const_cast<char*>($1.c_str()),$T2)"
> requires flx_strutil;
>
> fun foo (s:string) = {
> print $ "foo: " + s; endl;
> return regmatch s with
> | ["0" - "9"]+ => s + ".0"
> | _ => s
> endmatch;
> }
>
>
> fun format_real[T with Real[T]] (t:T, precision:int) : string = {
> var format = f"%%.%ig" precision;
> val s:string = vsprintf (format, t);
> print s; endl;
> return foo s;
> }
>
> print $ format_real (1.0, 12); endl;
> #######################################################
>
> with:
>
> SYSTEM FAILURE
> Attempt to register instance 5876[<T5137>] with type variable in a subscript
>
> -------------------------------------------------------------------------
> 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
>
-------------------------------------------------------------------------
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