This is not currently possible, and I am ambivalent about the idea. The problem 
with this
kind of default is that it leads to syntactic confusion which can lead to 
errors. I like
the discipline of always typing the value you intend, because it is this 
intention that
should be made clear.

Also, missing out parameters only works if there is one, or if it is the last 
of a list,
otherwise the prototype correspondence gets broken. I think the ambiguity is 
potentially
too dangerous for a mission critical application.

Bryan Ramirez wrote:
> Hi,
> 
> 
> I was wondering if there is a way to set a default argument for a body
> in cf3.
> 
> For example, I have something like this that I use everywhere:
> 
> body copy_from copyfrommaster(path) {
> ...
> }
> 
> I would like to add the option of turning on purge since I now need it
> in one spot.  However, I don't want to have to explicitly turn it off
> every other time I use this body definition.  It'd be nice to have
> something like this:
> 
> body copy_from copyfrommaster(path, purge => "false") {
> ...
>      purge => "${purge}";
> ...
> }
> 
> This would default the "purge" argument to false, but I wouldn't have to
> change all of my existing code.  Right now I'm doing this:
> 
> body copy_from copyfrommaster_purge(path) {
> ...
>      purge => "true";
> ...
> }
> 
> 
> Is there a way to do this.. and if not, can this be added?
> 
> Thanks!
> -Bryan
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine

-- 
Mark Burgess

-------------------------------------------------
Professor of Network and System Administration
Oslo University College, Norway

Personal Web: http://www.iu.hio.no/~mark
Office Telf : +47 22453272
-------------------------------------------------
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to