Unifying filters and functions? [Was: Re: Show inverted filter result]

Ondrej Zajicek santiago at crfreenet.org
Mon Mar 26 01:37:14 CEST 2012


On Thu, Mar 22, 2012 at 02:57:20PM +0100, Benjamin Cama wrote:
> Hi Ondrej,
> 
> Le jeudi 22 mars 2012 ?? 11:45 +0100, Ondrej Zajicek a écrit :
> > One possible way is to write filters as functions (returning true or false)
> > and then use 'where' to create filters: 'import where xxx()',
> > 'show route where ! xxx()'.
> 
> This makes me think about why is there a difference between functions
> and filters in the first place? Yes, functions accept argument, but
> then? They return a value??? a bit like filters return a decision. So,
> what's really the big difference?

IMHO functions are more general that filters, i don't really see why there
are explicit named filters here. One minor advantage is that named filters
are displayed in 'show protocols all'.

> I am wondering: is there a way to unify both? Do you think it's a good
> idea? Do you have suggestions on how to do that? (i.e. we should do it
> in a backward compatible fashion)

I think that the simplest way is just to not use named filters.

> The way I see it, I would make filter into functions that return
> booleans, and change 'accept' and 'reject' into ???aliases??? to 'return
> true' and 'return false'. Concerning the message attached to them, I
> don't really know??? Make these keywords a bit more specials and make them
> 'print xxx; return true/false;'?

This is not a good idea - you could use accept/reject even in function
(but it has different meaning - do not propagate return value and
accept/reject immediately). You could have a boolean function whose
return value has a different meaning than accept/reject, and the
function could internally call accept or reject in some cases. So the
suggested change definitely wouldn't be backward compatible.

-- 
Elen sila lumenn' omentielvo

Ondrej 'SanTiago' Zajicek (email: santiago at crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20120326/61feba4a/attachment-0001.asc>


More information about the Bird-users mailing list