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

Replace Nullable with Option in assemblyscript #944

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

fetsorn
Copy link
Contributor

@fetsorn fetsorn commented Jun 22, 2022

Replaces custom Nullable type with Option type from as-container. Resolves #809.

Recap:
We want to represent values which could be "null". Assemblyscript has nullable reference types, e.g. "string | null", but does not support nullable basic types, e.g. "u32", so we wrap primitives in a custom Nullable type, like "Nullable".

This PR wraps basic types in an Option container, like "Option.Some(10)" and "Option.None()". The Option container comes from has a robust implementation and a rust-inspired interface, similar to the Result type we are already using.

This PR does not wrap reference types in Option, they are still implemented as " | null" because " | null" allows for optional fields in the the input arguments to the bindings. Option does not allow optional fields, all missing arguments have to be written as Option.None<>().

  • Replace Nullable with Option

@fetsorn fetsorn changed the title 809 option type Replace Nullable with Option in assemblyscript Jun 22, 2022
@cbrzn cbrzn changed the base branch from prealpha to prealpha-dev June 22, 2022 10:39
@fetsorn fetsorn closed this Jun 22, 2022
@fetsorn fetsorn reopened this Jun 23, 2022
@fetsorn fetsorn marked this pull request as ready for review June 23, 2022 16:42
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

Successfully merging this pull request may close these issues.

2 participants