Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide "immutability" strategy - viz. Math::Matrix #5

Open
librasteve opened this issue Apr 22, 2022 · 0 comments
Open

Decide "immutability" strategy - viz. Math::Matrix #5

librasteve opened this issue Apr 22, 2022 · 0 comments

Comments

@librasteve
Copy link
Owner

librasteve commented Apr 22, 2022

Currently only splice() and .data[] = are a Series/DataFrame mutators
So to make these objects read only (ie a soft version of immutable) can be done this way:

  1. add a new has Bool $!ro = True; attr
  2. add a new override method rw { $!ro = False } (you can manually override ro behaviour twiw)
  3. and a new reset method ro { $!ro = False }
  4. and a new clone method clone { ... } with :rw adverb
  5. error if splice() or data[]= operations are attempted if $!ro [ie. splice is forbidden]
  6. check that dyadic operations now work like this c = a.concat(b); [ie. a,b immutable]
  7. implement this by psuedo-code:
method concat( \b ) {
    my c = a.clone( :rw );
    c.concat(b);      #the mutating concat we have now (which may contain mutating c.splice(b) operations)
    c.ro;
    c
}

oh and check grep

there are some interesting comments here

maybe concat can just use concat eg.. method concat( @b ) { |self, |@b }

oh and prevent write access to .data (eg. wrapper)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant