Re: [Puppet Users] Re: leading double colons (::) for class instances

2019-01-08 Thread Henrik Lindberg

On 2019-01-08 15:16, jcbollinger wrote:



On Monday, January 7, 2019 at 3:37:46 PM UTC-6, Matt Zagrabelny wrote:



On Mon, Jan 7, 2019 at 3:31 PM Matt Zagrabelny > wrote:

Greetings puppet-users!

For many years I have been using the following convention for
including my classes:

class foo() {
     include ::profile::bar
}

I know I don't need the leading double colon for including
profile::bar, but at one point in time I thought it may have
been a best practice or it would help prevent some sort of
future pain point.

Is that still true? Was I ever correct?

Needed to spend 30 more seconds reading before hitting send. Sorry
for the noise!

https://github.com/voxpupuli/puppet-lint-absolute_classname-check/issues/3


Thanks for any additional feedback!


I observe that the voxpupuli thread slightly downlplays the scope of the 
issue as it affected Puppet 3.  Puppet's (long since removed) relative 
name resolution scheme looked not just at the namespace in which the 
name was used, as the voxpupuli discussion seems to suggest, but also at 
every ancestor namespace, in order, until ultimately reaching top 
scope.  I'm not sure where to find P3 docs any longer, but this behavior 
is summarized in the description of PUP-121 
, the issue for removing 
that behavior.


That only rarely bit people, but it bit enough people, often enough, 
that for a time it was considered best practice to always use 
fully-qualified names (which is effectively what the `::` prefix 
produces).  But Puppet, Inc. decided that the negatives of relative name 
resolution outweighed the positives, including the positive of 
minimizing breaking changes, so relative name resolution was removed in 
Puppet 4.  Nowadays, the :: prefix is accepted for backwards 
compatibility, but it conveys no additional meaning.




Adding to what John said above:

There is no additional meaning for class names when it starts with '::', 
it does however make a difference when referencing variables. If a 
variable contains '::' (anywhere) it is always taken as an absolute 
reference starting from topscope. Thus something like '$::x' is the 
topscope $x, a '$x' is a local, inherited or topscope variable 'x', and 
'$x::y' and '$::x::y' are exactly the same thing.


- Henrik


John

--
You received this message because you are subscribed to the Google 
Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to puppet-users+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/325d0f92-98a4-462c-9378-ae189a22be5c%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.



--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/q12hcf%246fs%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: leading double colons (::) for class instances

2019-01-08 Thread jcbollinger


On Monday, January 7, 2019 at 3:37:46 PM UTC-6, Matt Zagrabelny wrote:
>
>
>
> On Mon, Jan 7, 2019 at 3:31 PM Matt Zagrabelny  > wrote:
>
>> Greetings puppet-users!
>>
>> For many years I have been using the following convention for including 
>> my classes:
>>
>> class foo() {
>> include ::profile::bar
>> }
>>
>> I know I don't need the leading double colon for including profile::bar, 
>> but at one point in time I thought it may have been a best practice or it 
>> would help prevent some sort of future pain point.
>>
>> Is that still true? Was I ever correct?
>>
>>  
> Needed to spend 30 more seconds reading before hitting send. Sorry for the 
> noise!
>
> https://github.com/voxpupuli/puppet-lint-absolute_classname-check/issues/3
>
> Thanks for any additional feedback!
>
>
I observe that the voxpupuli thread slightly downlplays the scope of the 
issue as it affected Puppet 3.  Puppet's (long since removed) relative name 
resolution scheme looked not just at the namespace in which the name was 
used, as the voxpupuli discussion seems to suggest, but also at every 
ancestor namespace, in order, until ultimately reaching top scope.  I'm not 
sure where to find P3 docs any longer, but this behavior is summarized in 
the description of PUP-121 , 
the issue for removing that behavior.

That only rarely bit people, but it bit enough people, often enough, that 
for a time it was considered best practice to always use fully-qualified 
names (which is effectively what the `::` prefix produces).  But Puppet, 
Inc. decided that the negatives of relative name resolution outweighed the 
positives, including the positive of minimizing breaking changes, so 
relative name resolution was removed in Puppet 4.  Nowadays, the :: prefix 
is accepted for backwards compatibility, but it conveys no additional 
meaning.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/325d0f92-98a4-462c-9378-ae189a22be5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: leading double colons (::) for class instances

2019-01-07 Thread Matt Zagrabelny
On Mon, Jan 7, 2019 at 3:31 PM Matt Zagrabelny  wrote:

> Greetings puppet-users!
>
> For many years I have been using the following convention for including my
> classes:
>
> class foo() {
> include ::profile::bar
> }
>
> I know I don't need the leading double colon for including profile::bar,
> but at one point in time I thought it may have been a best practice or it
> would help prevent some sort of future pain point.
>
> Is that still true? Was I ever correct?
>
>
Needed to spend 30 more seconds reading before hitting send. Sorry for the
noise!

https://github.com/voxpupuli/puppet-lint-absolute_classname-check/issues/3

Thanks for any additional feedback!

-m

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOLfK3X9J%3DA%3DQNNSc9ipExGOv%2B9O_Rd5-u1dfmc1DCbetXf-0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.