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

Allow for a type to be defined as readonly #373

Open
jimbxb opened this issue Jan 5, 2023 · 1 comment
Open

Allow for a type to be defined as readonly #373

jimbxb opened this issue Jan 5, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jimbxb
Copy link
Collaborator

jimbxb commented Jan 5, 2023

A readonly type would be a type that, once a value of this type is defined, cannot be modified using any of the usual mutators defined automatically for a type.

The implementation of this should be as simple as only creating the getters (not mutators) for a readonly type. However, it might just be better to make the mutators private, as this would allow modifications to a value inside the type, but not outside.

A type could be defined to be readonly using the type modifiers we have currently for unique types. A la

type {readonly} tuple(A, B) { tuple(fst:A, snd:B) }
@jimbxb jimbxb added enhancement New feature or request good first issue Good for newcomers labels Jan 5, 2023
@jimbxb
Copy link
Collaborator Author

jimbxb commented Jan 5, 2023

This could also be extended to each field for greater granularity.

type entity { player({readonly} id:int, stats:stats, inventory:list(item)) | enemy({readonly} id:int) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant