On 14.07.2009 15:54 Uhr, Jan Janak wrote:
On Fri, Jul 3, 2009 at 6:45 PM, Daniel-Constantin
Mierla<miconda(a)gmail.com> wrote:
whose confusion?
like the discussion on
lookup_domain function revealed, it is confusing
that the same prefix ($ char) is used for two different things.
from my point of view, all are script variables: avps, references to sip
message parts, etc ... therefore the have to start with same char, and most
of the programming languages use $ for that. It is what was decided long
time ago in openser when pseudo-variables were introduced in core.
Actually, those programming languages that use delimiting characters
for symbols often use different symbols for different categories of
symbols.
the alphabet is exhausted already if you think this way -- there are lot
of PV classes by now.
See, for example, this wikipedia page for some
examples and
historic perspective:
http://en.wikipedia.org/wiki/Sigil_(computer_programming)
Most of the pseudo variables, are, in fact, just hidden functions that
perform complex magic to retrieve a piece of information from the SIP
message, for example.
same is for avps - a hidden function accessing a linked list
in shared
memory. Moreover, ser mode of avps encodes the list in the name (in K
there is only one avp list, while in S are couple of them). Further,
$shv(xyz) is accessing a fixed location in shared memory, $var(abc) is
accessing a fixed location is private memory, a.s.o. ... we can move all
to $ or all to @.
Daniel
This is definitely true for selects in SER and
it is, as far as I can tell, true for many of the PVs in Kamailio.
When it comes to selects in SER, they are basically nothing more than
just function names constructed in a special way. We use the '@'
delimiter at the beginning of the function name to denote that this is
a special kind of function which cannot be used like other function in
the routing part of the script. There is no reason why selects should
use the same delimiter that is used for variables (in case of SER AVPs
because there are no real variables).
Basically, there are classes of script variables,
some accepting dynamic
names (like avps $avp(...), headers $hdr(...), private $var(...) and shared
variables $sht(...) a.s.o.).
I do not see reason for a special character for certain classes, like avp or
select. It is much much clearer to have:
$avp(name)
$sel(name)
Why is it clearer to overload one delimiter for different kinds of
symbols than to use multiple delimiters? Under the hood, selects are
something completely different than AVPs. Pseudo variables like $fd
are something very different than $var(..), and so on.
And if this is the preferred approach, wouldn't it make more sense to
call functions as $func(name) as well? Just to be consistent?
rather than:
$name for avps
@name for selects
&name, %name etc. for what so ever variable class
This form is much more compact, easier to read, and also similar to
how other programming languages treat different categories of symbols.
Note that in your example above you do the same thing, only in a more
complex way.
Jan.
_______________________________________________
sr-dev mailing list
sr-dev(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev