[erlang-questions] At what point am I "playing compiler"

Thomas Lindgren thomasl_erlang@REDACTED
Mon May 18 18:10:31 CEST 2009






----- Original Message ----
> From: Richard Carlsson <richardc@REDACTED>
> Currently, the following seem to be handled:
>   all/2, any/2, foreach/2, map/2, flatmap/2, filter/2, foldl/3, foldr/3,
>   mapfoldl/3, mapfoldr/3.
> 
> I implemented this years ago, along with the inliner. (I expected the
> inliner to be able to reduce these further, when the fun is given
> explicitly, but something seems to prevent this from happening at
> present - needs more investigation, but the inliner is complicated.)


My experiences were quite encouraging when specializing roughly the same collection of functions. (But my optimizer did beta-reduce those function calls.)

> OTP kept it in there for experimental purposes, but weren't too excited
> about it because: 1) it changes the semantics so that even if the lists
> module is upgraded, these calls will stay as they were at compile time
> (not that I think that will ever be a problem); 2) there is of course
> code duplication - each such call becomes a separate little loop
> function 0 (but so do list comprehensions); 3) debugging is affected,
> because code that crashes in these functions will have different stack
> traces compared to plain calls to the lists module;


Point 1 would be handled by declaring lists as preloaded.

Point 2 and 3: we already have list comprehensions behaving like that, so I don't think this is a fundamental weakness. OTP just have to make the leap :-)

Best,
Thomas



      




More information about the erlang-questions mailing list