[Bro-Dev] #972: Default arguments for functions

Bro Tracker bro at tracker.bro.org
Fri May 3 11:26:07 PDT 2013

#972: Default arguments for functions
  Reporter:  robin            |      Owner:
      Type:  Feature Request  |     Status:  new
  Priority:  Low              |  Milestone:  Bro2.2
 Component:  Bro              |    Version:  git/master
Resolution:                   |   Keywords:

Comment (by jsiwek):

 I've got some new code that allows default params and seems to work so
 far.  An example script:

 global foo: function(a: string &default="hello");

 # TODO: adding &default should be optional on impl if decl has it?
 function foo(a: string &default="hello")
     print "foo", a;

 function bar(a: string, b: string &default="hi", c: count &default=5)
     print "bar", a, b, c;

 # TODO: should be a parse error?
 # (i.e. follow C++ rules that default params must be rightmost ones)
 function baz(a: string &default="err", b: string)
     print "baz", a, b;


 bar("cool", "beans");
 bar("cool", "beans", 13);

 Thoughts on the questions in the TODO comments?

Ticket URL: <http://tracker.bro.org/bro/ticket/972#comment:1>
Bro Tracker <http://tracker.bro.org/bro>
Bro Issue Tracker

More information about the bro-dev mailing list