develooper Front page | perl.perl5.porters | Postings from March 2023

Re: Pre-RFC Deep constants

Thread Previous | Thread Next
From:
Branislav Zahradník
Date:
March 9, 2023 19:43
Subject:
Re: Pre-RFC Deep constants
Message ID:
CAB=rbOkTb6qJcGXbsEF9mye7HBD9w9fLzecJggZdgjdobCHqTQ@mail.gmail.com
Few short assorted thoughts:

- write once behaviour will be great
   - referring to my earlier proposal for `not-exists` value - define
behaviour: constant not-existing value can be assigned once

- perl core imho needs to rework magic (I'd vote for function tables per SV
- where function table will be on par with packages / class literals)

- should there be an mechanism to turn it on/off in runtime?, eg
  my $var = { ... };
  foo ($var : const);
  $var->{bar} //= default value;
  return $bar;

- how it should behave when returning copy? clone / copy-on-write? eg:
  state $var :const = { ... };
  return $var : copy-on-write;

- can it be localized? If localized, should it still be "deep constant" ?

- how initialization with read-write data will behave?, eg:
  my $foo = { ... };
  my $bar : const = { foo => $foo };

- it will be also nice to be able to bound read-write to visibility of
symbol(s) (aka protected)
  - class may mark its instance as conditional read only
  - user may mark instance as fully read-only

Brano

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About