On Fri, Jul 3, 2009 at 6:45 PM, Daniel-Constantin Mierlamiconda@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. 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. 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.