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

[FEAT] Addition of an OR operator for types #46

Open
Calamixy opened this issue Jan 1, 2024 · 2 comments
Open

[FEAT] Addition of an OR operator for types #46

Calamixy opened this issue Jan 1, 2024 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@Calamixy
Copy link

Calamixy commented Jan 1, 2024

Describe your feature

The addition of an OR operator for types will create better data definitions with less overhead, compared to tagged enum alternatives. The operator can function similar to Luau i.e. type bool_or_u8 = boolean | u8

Alternatives

Using tagged enums will in essence function as an OR, however there is more overhead.
i.e.

enum "Type" {
    Number {
        Value: f64,
    },

    String {
        Value: string,
    },
}

WILL CREATE -->

({
	Type: "Number",
	Value: (number),
} | {
	Type: "String",
	Value: (string),
})

meaning that there is now an overhead of both a string and the value's type.

@Calamixy Calamixy added the enhancement New feature or request label Jan 1, 2024
@sasial-dev
Copy link
Collaborator

sasial-dev commented Jan 2, 2024

Implimentation Details:

  • OR would have | syntax like type Test = f64 | string
  • OR should parse to a list not a tree
  • OR would only work for primatives
  • OR will error if two types of numbers are added to the list
  • OR can be optional like type Test = (f64 | string)?.

@sasial-dev
Copy link
Collaborator

sasial-dev commented Jan 2, 2024

This issue will be done with the convert rewrite - expect it in 0.7.0.

@sasial-dev sasial-dev modified the milestones: 0.7 Release, 0.6 Release Jan 2, 2024
@sasial-dev sasial-dev removed this from the 0.7 Release milestone Mar 23, 2024
@sasial-dev sasial-dev added this to the 0.7 Release milestone Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants