Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1153704]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-28 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found