in reply to Implicit references? module -> feature -> pragma -> "Perl8" ?
Isn't a language extension for a rather rare use case kind of overenineered? Wouldn't a read-only reference be sufficient and at the same time more flexible and better readable? Explicitly creating a read-only reference is clearly visible and lets you choose any name.
Readonly has the clumsy named sub Scalar1. Just rename it.
#!/usr/bin/perl use v5.14; use warnings; use Readonly (); BEGIN { *ro_ref = \&Readonly::Scalar1; } my @arr = (2, 3, 4); ro_ref my $arr, \@arr; @arr = (3, 4, 5); say "@$arr"; eval {$arr = [4, 5, 6]; 1} || warn $@; __DATA__ Modification of a read-only value attempted at /home/jo/Programs/play- +scripts/ro-ref.pl line 16. 3 4 5
Greetings,
🐻
|
|---|