Skip to content

Instantly share code, notes, and snippets.

@0racle
Last active May 27, 2016 07:07
Show Gist options
  • Save 0racle/985428b55796a621d366e65661018688 to your computer and use it in GitHub Desktop.
Save 0racle/985428b55796a621d366e65661018688 to your computer and use it in GitHub Desktop.
Read Only
> my $a = 10
10
> my $x := $a
10
> $x = 5
5

😞

> my $x ::= $a;
===SORRY!===
"::=" not yet implemented. Sorry.

😭

sub prefix:<ro> ($val) {
    Proxy.new(
        FETCH => method { $val },
        STORE => method (|) { X::Assignment::RO.new.throw }
    )
}

> my $x := ro $a;
10
> $x = 5;
Cannot modify an immutable value

😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment