Issue #13210 has been updated by Chris Price.

I discussed this with Matt Robinson, who had been involved to some degree with 
the original ticket.  His recollection was that there were arguments for both 
of the two approaches--so it does not sound like there was an overwhelming 
argument in support of the current behavior.

It seems to me that an important consideration here is: "what is the target 
audience of the function definition API?"  If we're targeting developers, then 
I don't think it's unreasonable to expect authors to know that they may need to 
account for nil or :undef values being passed in as arguments.  If we're 
targeting a broader audience and making the function definition as simple as 
possible is the primary goal, then I can perhaps see the case for passing 
undefs as empty strings.

My overall take on this, though, is that there are cases in the world where 
there is a meaningful semantic distinction between "null" and an empty string 
(plenty of precedent for this in relational databases, etc.), and that our 
current implementation explicitly prevents users from handling that 
distinction.  Thus I'd be inclined to mark this ticket as accepted and propose 
that we change the behavior... probably to passing 'nil'.

Will leave this ticket open for comments for a while and see if there are 
strong feelings one way or the other.
----------------------------------------
Bug #13210: undef changes into '' when passed to function as a param
https://projects.puppetlabs.com/issues/13210#change-58703

Author: Timur Batyrshin
Status: Investigating
Priority: Normal
Assignee: Chris Price
Category: 
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


Suppose we have a manifest like that:
<pre>
define foo ( $x = '1' ) {
  notify { "x${x}": }
}

class bar {
  $x = myfunc( undef )
  foo {'no1': x=> $x }
}

class baz {
  $x = undef
  foo {'no2': x=> $x }
}


include bar
include baz
</pre>

With myfunc() defined like that:
<pre>
module Puppet::Parser::Functions
    newfunction(:myfunc, :type => :rvalue) do |param|
      return param
    end
end
</pre>

When applying the manifest we get the following output.
<pre>
notice: x
notice: /Stage[main]/Bar/Foo[no1]/Notify[x]/message: defined 'message' as 'x'
notice: x1
notice: /Stage[main]/Baz/Foo[no2]/Notify[x1]/message: defined 'message' as 'x1'
notice: Finished catalog run in 0.06 seconds
</pre>

However the same message should be produced in both calls to foo.



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to