[asterisk-dev] Parsing in Asterisk
Leif Madsen
leif.madsen at asteriskdocs.org
Mon Mar 19 07:15:33 MST 2007
On Tuesday 13 March 2007 19:26:06 Matthew Nicholson wrote:
> Tilghman Lesher wrote:
> > [...]
> >
> > This leads me to my first conclusion: we need to remove the transparent
> > translation, preferring the comma as our argument delimiter. I am aware
> > that this is a significant change and it will require a flag day,
> > because all applications currently parse on the pipe character.
> > However, I believe that this is necessary to allow Asterisk dialplans to
> > become more complex without sacrificing readability.
> >
> > [...]
>
> Personally, I like the '|' better than the ','. Mostly because that is
> what I am used to using, but it seems that dropping the ',' would be
> easier on Asterisk applications than dropping the '|' would be. I also
> find dialplans using the '|' easier to read (although ', ' as can be
> commonly found in C is also easy to read, but currently apps will use
> that ' ' instead of ignoring it).
Honestly, I use a mix of pipes and commas where it makes it aesthetically easy
on the eyes. Some situations call for pipe, where others call for comma. But
if it's gotta be one or the other, most people I've spoken to do seem to
prefer comma over the pipe (there's more whitespace there, thus easier to see
separation).
For example, when using the HASH() function, I find it easier on my eyes to
use a pipe because it registers in my mind as a column separator:
${HASH(MY_FUNKY_HASH|column_name)}
But using CUT() it seems to make more sense to me to use a comma:
${CUT(CHANNEL,#,2)}
Or these mixed usage examples (taken from my dialplan):
Set(MEMBER=${DUNDILOOKUP(${CUT(MEMBER,/,2)}|clients|b)})
Set(HASH(GROUP_MEMBER)=${HUNT_GROUP_MEMBERS(${HASH(HUNT_${POS}|member_id)},
${GROUP_OFFSET})})
I have no real point here, other than that I like both I guess :)
Leif Madsen.
More information about the asterisk-dev
mailing list