Skip to content

StringOwnership

Isaac Shelton edited this page Sep 8, 2023 · 9 revisions

StringOwnership

Specifications

Type Size Memory Management Model File
StringOwnership 8 bytes None 2.7/String.adept

Definition

enum StringOwnership (REFERENCE, OWN, GIVEN, DONOR)

Values

Enum Value Purpose After __pass__(String) After __assign__(*String, POD String)
StringOwnership::REFERENCE Reference String REFERENCE REFERENCE
StringOwnership::OWN Owned String REFERENCE REFERENCE
StringOwnership::GIVEN Transfer String OWN OWN
StringOwnership::DONOR Donor String DONOR REFERENCE

Purpose

StringOwnership is used to represent the different states that a String value can be in.

Ownership Manipulation

When String values are passed to functions/methods, they are converted to kind StringOwnership::REFERENCE if they are StringOwnership::OWN, so that the callee doesn't take responsibility for freeing them. If they are StringOwnership::GIVEN, then they are converted to kind StringOwnership::OWN, so that the callee now has responsibility of freeing them. When String values are donate()d, they will be converted to kind StringOwnership::DONOR, to indicate that the string has donated ownership and therefore doesn't retain information about the given value.

Clone this wiki locally