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

On Sized Types and Rereference Counting References #97

Open
DavePearce opened this issue Jul 7, 2021 · 0 comments
Open

On Sized Types and Rereference Counting References #97

DavePearce opened this issue Jul 7, 2021 · 0 comments

Comments

@DavePearce
Copy link
Member

DavePearce commented Jul 7, 2021

Some observations about array types:

  • int[] is a dynamically sized array with a known length. Accesses can be checked.
  • int[8] is a fixed-size array. Again, accesses can be checked.
  • int[n] is a dynamically sized array with a known length determined by some variable n currently in scope. Again, accesses can be checked.
  • int[?] is a dynamically sized array with an unknown length. Accesses cannot be checked.

Based on this model, we can extend to references as follows:

  • &int is a reference with an dynamically sized but known number of referents. Deletion can be checked.
  • &int:1 is a reference with a statically sized known of references. Deletion can be checked.
  • &int:n is a reference with a dynamically sized number of referents determined by some variable n currently in scope. Again, deletion can be checked.
  • &int:? is a reference with an unknown number of referents. Deletion cannot be checked (though it could be disallowed).

An interesting question here is how you create an instance of e.g. &int:2. Presumably, something like the following would be necessary:

&int:1 p = new 123
(&int:2 q, &int:2 r) = (p,p)

A similar question is how you would destroy such a reference.

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