Erlang Mailing Lists

Author Message

<  User Contributions  ~  Currying parse transform

vladdu
Posted: Fri Sep 08, 2006 12:11 pm Reply with quote
User Joined: 28 Feb 2005 Posts: 397 Location: Gothenburg, Sweden
Hi!

By reusing an older utility function by Ulf Wiger, I've written a parse transform that looks for function calls with "don't care" arguments (which are illegal Erlang!) and replaces them with a functional expression currying the original on the missing arguments.

So if you write
Code:
    my:ff(2, _, erl, _, ang)

it will be transformed to
Code:
    fun(V1, V2) -> my:ff(2, V1, erl, V2, ang) end


This idea of "currying on steroids" is borrowed from Nemerle (www.nemerle.org)

Warning: The implementation has a funny gensym() implementation, so I'd not use it "as is" in a production environment.

Enjoy!
/Vlad



curry.erl
 Description:

Download
 Filename:  curry.erl
 Filesize:  4.1 KB
 Downloaded:  1331 Time(s)

View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum