Tue Sep 23 15:04:42 CEST 2003
On Tue, 23 Sep 2003, Richard Carlsson wrote:
> On Tue, 23 Sep 2003, Joe Armstrong wrote:
> > Has anybody (Luke?, Robert?) got a source->source Erlang transformer
> > that expand out
> > - records
> > - funs
> > - list-comprehensions
> > - if/case/receive
> > This is prettry similar to erl_lint + sys_pre_expand only brought
> > up-to-date for list-comprehensions and records.
> sys_pre_expand already *does* expand away records and list
> comprehensions (do "c(foo, ['E'])." and look at the "foo.E" file).
Sorry - I'd forgotten aabout the records - but the expansion of list
comprehensions is missing ...
> Adding a pass to expand ifs to normal cases should be simple (there used
> to be a template parse transform file somewhere - under stdlib I think -
> but I can't find it in the current distribution). Or just hack
> sys_pre_expand to do it for you - it should not make any difference
> if it is done there or later (well, the debugger could be confused).
Yup - done this before :-)
> Funs should _not_ be "expanded" however, as long as you're still on this
> level - it's a *big* mistake to expose the actual implementation of
> closures until you get to the really low level code.
This where I am of two minds. One part of me says implement funs
by lambda-lifting and transforming into regular first-order code
(and yes I know you have to "cheat" with the odd funny atom name :-)
The other part says make "proper" closures (internally) - both
approaches have advantages and disadvantages.
IMHO the difficult bit in an implementation is the layering - what goes into
> Richard Carlsson (richardc@REDACTED) (This space intentionally left blank.)
> E-mail: Richard.Carlsson@REDACTED WWW: http://user.it.uu.se/~richardc/
> "Having users is like optimization: the wise course is to delay it."
> -- Paul Graham
More information about the erlang-questions