Imagine that you have this code:

exten => _X!,n,Set(foo=${QUEUE_WAITING_COUNT(${QueueName})}))

If ${QueueName} happens to be unset, this will cause a warning:

[Jul 22 14:26:17] ERROR[8114]: app_queue.c:5187
queue_function_queuewaitingcount: QUEUE_WAITING_COUNT requires an
argument: queuename

The obvious solution:

exten => _X!,n,ExecIf($["${QueueName}" != 
""]?Set(foo=${QUEUE_WAITING_COUNT(${QueueName})}))

However, this doesn't actually work! Functions and variables on the
right hand side are evaluated BEFORE it is decided whether it needs to
be executed at all!

This is fairly harmless in this case, in that it just causes a warning.
However, what about this case?

exten => _X!,n,ExecIf($[${bar} < 10]?Set(foo=${INC(bar)}))

Which you can argue that this code is in poor taste, it is definitely
surprising that INC is evaluated in this case, changing ${bar} even if
${bar} >= 10.

It probably isn't possible to do something about this, but now you have
all been warned... This could be a good reason for avoiding side effects
in functions, and thereby banning ${INC()}


/Benny



_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to