Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Readonly oddity

by dmitri (Priest)
on Jan 26, 2016 at 20:58 UTC ( [id://1153704] : note . print w/replies, xml ) Need Help??


in reply to Readonly oddity

Readonly was a subject of my lightning talk Quick, to the Volcano! It is also on YouTube somewhere.

I know you did not ask this, but (we people from USSR love to give advice): avoid Readonly and use constant instead.

Replies are listed 'Best First'.
Re^2: Readonly oddity
by BillKSmith (Monsignor) on Jan 26, 2016 at 23:00 UTC

    I disagree with your advice to avoid "Readonly" for several reasons:

    Readonly variables interpolate into strings.

    Readonly can protect an entire complex data structure.

    Readonly can be removed easily from production code if constraints on speed or space require it.

    Bill
Re^2: Readonly oddity
by zwon (Abbot) on Jan 26, 2016 at 23:38 UTC
    I don't agree with this advice either. I personally don't like constant because it is not suitable for any complex structures and you can't interpolate those constants in strings. Neither I like Readonly because you have to type "Readonly", which is quite a lot and the capital 'R' makes it simply unbearable. So I use Const::Fast.
      > I personally don't like constant because it is not suitable for any complex structures

      For example?

        The documentation for constant explains this.

        "For example?"

        The NOTES section of that documentation has an example.

        — Ken