[Asterisk-Users] How do i make best use of Macro?

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Wed Jun 11 11:37:32 MST 2003


On Wednesday 11 June 2003 01:01 pm, Christopher Arnold wrote:
> On Wed, 11 Jun 2003, Tilghman Lesher wrote:
> > On Wednesday 11 June 2003 10:43 am, Christopher Arnold wrote:
> > > a) Is there state building up if my macro calls itself
> > > recusivly?
> >
> > A macro is NOT a function.  It simply is a shortcut to doing a
> > longer series of commands.  A macro cannot itself be recursive.
>
> Hmm shame on me...
> So that is why it is called a Macro! :-)
>
> > > Or should i use a Goto(newcontext,s,1)?
> >
> > I think you're confused as to what a macro can and cannot do. 
> > Until you understand that distinction, you're going to have
> > trouble understanding how a macro works within the system.
>
> Shure i am. So i really should se a macro as something close to a
> #define in C?

Quite analogous.

> > In any case, I'd recommend that you forget about using macros
> > and instead use AGI.
>
> I had the impression that it was possible without AGI, but ok ill
> follow the oracles advice. Does anyone have any pointers to
> documentation on the AGI interface?

http://asterisk.drunkcoder.com/agi.cgi

It certainly is possible without AGI, but then again, I tend to code
stuff in C even when it probably would be faster to write in Perl and
AGI.

> Another state question:
> It would be possible to implement my functionality with a circle of
> contexts. (I actually have a running proof of concept
> implementation) But how is it in this case, would asterisk build up
> a huge state if someone rotates around to much in the loop of
> contexts?

As you aren't calling functions, you aren't creating a deeper stack,
and therefore, aren't accumulating additional state information.
Every branch is just a jump, with no return address stored.
Subroutines might be in the future of the Asterisk extension logic,
but they aren't there now.

-Tilghman




More information about the asterisk-users mailing list