On Tuesday 30 August 2022 at 18:17:08, Mark Murawski wrote:
> On 8/30/22 11:16, Antony Stone wrote:
> > If I write in my AEL dialplan:
> > Set(Tracker=${CDR(uniqueid)});
> >
> > this results in executing:
> > Set(Tracker=eagle.domain.com-1661872057.2349)
> >
> > Just what I want.
> >
> > However writing:
> > Tracker=${CDR(uniqueid)};
> >
> > results in:
> > MSet(Tracker=-1661872057.2349)
> >
> > systemname is missing.
>
> Hi Antony,
>
> This is not a problem with MSet.
No, it is indeed the documented behaviour of MSet "MSet behaves in a
similar
fashion to the way Set worked in 1.2/1.4 and is thus prone to doing things
that you may not expect."
> Keep in mind that AEL is a transpiler, the AEL itself is not evaluated
> at the time of execution... extensions.conf-style dialplan is what's
> being executed.
Agreed.
> Also... keep in mind that var=val assignments always use surround the
> value with $[] which will either evaluate math or boolean expressions.
>
> Since 'eagle.domain.com' is not numeric, and not boolean, it's
expected
> it would not be included in the final value.
Yes, but to be fair, that is not what I would expect Tracker=${CDR(uniqueid)}
to do in any other language.
> If you do a 'dialplan show' on the context after AEL has processed
it,
> you'll clearly see the MSet and ${CDR(uniqueid)} being inside $[]
Yes.
> If you run the same code through extensions.conf you'll get exactly the
> same result... so I would call this expected behavior.
I think we'll have to disagree on what a programmer "expects" a
syntax like
var=value to do, then.
> The fix/workaround is to explicitly use Set() when you need to work with
> anything non-numeric and non-boolean
True, and that is precisely what I have been doing in order to avoid such
problems. This example slipped through my conversion process (I've been
converting previously-non-AEL dialplans into AEL because I prefer the general
style).
What I am suggesting is that Tracker=${CDR(uniqueid)} should be converted by
AEL into Set(Tracker=${CDR(uniqueid)}) in order to avoid this sort of
surprise.
If someone knows they want to perform arithmetic, they can write
Result=$[${var1}-4] and end up with Set(Result=$[${var1}-4]) after AEL has
done its transpilation.
Maybe you could offer an example of where MSet() does what most people would
expect, and Set() does not?
I still intend to abide by the documentation for MSet "Avoid its use if
possible.", and I simply think it would be good if AEL: did the same.
Antony.
--
+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
Please reply to the list;
please *don't* CC
me.