[asterisk-users] Function vs. Application?

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Fri Dec 7 15:12:03 CST 2007


On Friday 07 December 2007 14:19:49 Jared Smith wrote:
> On Fri, 2007-12-07 at 21:04 +0100, Vincent wrote:
> > Out of curiosity, what's the difference between a function and an
> > application?
>
> In a nutshell, an application is something that performs an action on a
> channel (such as playing a sound prompt, gathering DTMF input, putting
> the call into a call queue, etc.).
>
> A function, on the other hand, is used to get or set values, and doesn't
> directly manipulate the channel.  These values *might* have something to
> do with the channel (such as is the case with the CDR function), but
> don't necessarily have to (such as is the case with the CUT and LEN
> functions).
>
> Hopefully I've explained it in such a way that it's clearer to you know.
> If not, let me know and I'll try to be more clear.

You could also think of it as the difference between a procedure and a
function.  A procedure does something and returns nothing.  A function
may or may not be doing something, but its primary function is to return
a value.  Unlike other languages, in Asterisk, the return value of a function
may not be directly ignored (i.e. you HAVE to get it, even if you do nothing
with it).

Of course, setting a dialplan function completely ruins this nice dichotomy.
;-)

-- 
Tilghman



More information about the asterisk-users mailing list