[erlang-questions] case expression scope

Richard A. O'Keefe ok@REDACTED
Mon Mar 3 22:23:20 CET 2014


On 4/03/2014, at 8:07 AM, Daniel Goertzen wrote:

> Hmm, fun wrapping could be the basis of hygienic-case parse transform.  I'll have to see what the performance overhead of a fun wrap is like.
> 
> The example I gave is contrived and a bit weak I guess.  In my most recent run-in with this issue there were a lot of bindings from the enclosing scope that were used, so breaking things out to top level functions would not always be a good option.

I see a non-sequitur there.

Simplified examples are great for revealing bugs.

For illuminating style concerns, NOTHING beats REAL code.

"There were a lot of bindings from the enclosing scope"
is already a warning sign that the code should be restructured.

>  Funs would be better, but add clutter and maybe runtime overhead.

There is currently some run-time overhead.
In R16B03-1, the compiler still does not optimise

(fun (...) -> ... ... end)(...)

by turning it into the equivalent of an SML let ... in ... end
form, but there is no particular reason why it couldn't.

Whether you can _measure_ the overhead in a real application
is another matter entirely.

Splitting out little functions and then telling the compiler
to inline them might well have the least overhead of all.





More information about the erlang-questions mailing list