in reply to Implicit references? module -> feature -> pragma -> "Perl8" ?

Isn't a language extension for a rather rare use case kind of overengineered? 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,
🐻

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Replies are listed 'Best First'.
Re^2: Implicit references? module -> feature -> pragma -> "Perl8" ?
by LanX (Saint) on May 17, 2026 at 17:56 UTC
    That's true, but you are only seeing the mine @arr case, where it was until recently impossible to change the underlying \@arr reference.

    If you want to also cover the mine $arr=[] case, @arr := @$arr has to become magically adjusted or an alias or ...

    Update

    Till now most were only talking about the implementation, and that they reject the notion that equal symbols are bad or mostly useless.

    Nobody commented on the idea to simplify the syntax with implicit refs.

    FWIW: this could also be achieved by introducing another sigil like ¢ for automatic refs, hence avoiding a keyword mine

    But I seriously doubt this is doable and worth the trouble.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery