>
> In Felix you can do this:
> fun f(i:int) =>
>   let ?g = fun (x:int) => i + x in
>   g (i+2)
> ;
> but this is not the same: it makes g a closure. Closure can only
> be inlined away with data flow analysis, it may happen in this case
> but I wouldn't bet on it :)


There's no need to make bets, just try it out and look at the disassembly
to see what happens with your preferred compilers.

In CoffeeScript they only have the lambda syntax for definition functions;
i.e. they have f = fun (x) => x*x and NOT fun f(x) => x*x.  This works
surprisingly well and keeps the language nice and simple - now there's just
one function construct to support, and at little cost (basically just the
extra " = " in terms of character count; it's no harder to read, and its
trivial for the compiler to assign a name to the function when appropriate).

You could do the same transform - just treat val g = fun(x) => x*x as if
they had typed fun g(x) => x*x .

Cheers,

Dobes




On Wed, Jan 16, 2013 at 9:02 AM, john skaller <skal...@users.sourceforge.net
> wrote:

> I want to do this but I can't:
>
> fun f (i:int) =>
>   let fun g (x:int) => i + x in
>  g (i+2)
> ;
>
> I have to go to statement form:
>
> fun f (i:int) =
> {
>   fun g(x:int) => i + x;
>   return g(i+2);
> }
>
> That's a pain. Ocaml can do this because let introduces a function:
>
>         let x = 1 in
>         let f y = y + 1 in
>         ...
>
> In Felix you can do this:
>
> fun f(i:int) =>
>   let ?g = fun (x:int) => i + x in
>   g (i+2)
> ;
>
> but this is not the same: it makes g a closure. Closure can only
> be inlined away with data flow analysis, it may happen in this case
> but I wouldn't bet on it :)
>
>
> --
> john skaller
> skal...@users.sourceforge.net
> http://felix-lang.org
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Felix Language" group.
> To post to this group, send email to felix-langu...@googlegroups.com.
> To unsubscribe from this group, send email to
> felix-language+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/felix-language?hl=en.
>
>
------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to