More additions to unlang

Jakob Hirsch jh at plonk.de
Fri May 17 10:05:44 CEST 2013


Alan DeKok, 16.05.2013 23:51:
>   The changes in today add "compile-time" validation, and evaluation of
> static values.  For example:
> 
>  	if (Session-Timeout < blue) {

Is there any difference (functional or performance-wise) between this
and the previously posted form with the ampersand, i.e. "if
(&Session-Timeout < ..."?

>   Even better, parts of the virtual servers can now be removed at start
> time:

So it seem there's quite a lot of good stuff coming :)

Btw, if you are still looking for more ideas, what about this:

- ternary logic, like C's "condition ? yes : no"
This would save a bunch of lines, because instead of

if (some condition) {
  update reply {
    Some-Attribute := "foo"
    Session-Timeout := 600
  }
}
else {
  update reply {
    Some-Attribute := "bar"
    Session-Timeout := 600
  }
}

we could do a simple and short

update reply {
  Some-Attribute := (some condition) ? "foo" : "bar"
}

Not sure how easy this is to parse, though. Maybe something like
"%{cond ? true : false}" would be better.


- regex-like comparison operators
E.g. =^ and =$ would be true if the LHS starts/ends with the RHS string.
I.e.,

( "foobar" =^ "foo") -> true
( "foobar" =^ "bar") -> false
( "foobar" =$ "foo") -> false
( "foobar" =$ "bar") -> true

This would elimate the need for a lot of regex matches.


I never looked into the unlang code, but if I find the time, I could try
to implement it myself, but probably not for 2.x, now that 3.x is upcoming.



Regards
Jakob



More information about the Freeradius-Devel mailing list