Erlang Mailing Lists

Author Message

<  Erlang  ~  Suggestion - Application level exports.

dsmith
Posted: Mon Feb 04, 2008 11:24 am Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
I've started to write my first substantial applications in Erlang and am enjoying it very much.

However, I'm finding that it is difficult to organize my code the way I would like while maintaining access constraints.

There are many functions that I would like to make accessible within the application but not to other applications. To achieve this I end up putting more functions than I would like into just a few source files.

Has anyone ever suggested the possibility of application level exports?
View user's profile Send private message
Mazen
Posted: Mon Feb 04, 2008 3:23 pm Reply with quote
User Joined: 20 Jul 2006 Posts: 164 Location: London
Actually you already have that since everything in Erlang is based on modules. Making an application out of your modules is just adding an abstraction level on top and isn't acutally part of the language but rather an OTP one.

My suggestion would be to create a facade module. If your application is called "foo" then you have a module which is called "foo.erl" (typically also uses the application behaviour) and exports all the functions that are supposed to be used by external applications/modules (Mnesia is a good example of this). For the internal exports you just need to organize your modules better. An internal facade module (from where all your internal modules access functionality) would perhaps make sense if you have a really big and complex structure in your code, but so far I have never come across the need for it.

I get the feeling that you are thinking in a more object oriented fashion or maybe I'm misunderstanding you Smile

/Mazen
View user's profile Send private message
dsmith
Posted: Tue Feb 05, 2008 3:32 am Reply with quote
User Joined: 08 Aug 2007 Posts: 41 Location: Toronto
You are correct, I do come from an OO background and have a bias for access constraints. In the industry I work, where most business level programmers come out of 6 month Java training camps, highly constrained frameworks are a must. In fact it is the constraints built into Erlang that draw me to it -- single assignment; no data sharing between process.

I know the application is not a language level construct, and would have to be in order to scope exports to the application.

I have looked at mnesia and do see you're point. Although there are no restrictions to calling functions in a support module, if I keep the PIDs to my internal server and FSM's private, users will be unable mess thing up.

OK, thanks for you're help.
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 cannot download files in this forum