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

[Feature] Add an array generic type #391

Open
Ph0enixKM opened this issue Aug 6, 2024 · 3 comments
Open

[Feature] Add an array generic type #391

Ph0enixKM opened this issue Aug 6, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Ph0enixKM
Copy link
Member

Is your feature request related to a problem? Please describe.
The problem is that sometimes a person might want to match any Array type when declaring a function parameter.

fun len(array: []): Num {
    ...
}

Describe the solution you'd like

  • Add the [] syntax in Types
  • Handle the [] type only in function parameter types.

Describe alternatives you've considered
I've considered function overloading but it seems to be an overkill.

Additional context
This way we can more precisely specify the context and use of functions.

@Ph0enixKM Ph0enixKM added the enhancement New feature or request label Aug 6, 2024
@b1ek
Copy link
Member

b1ek commented Aug 8, 2024

what about adding explicit Any type and every time you need to put a generic type anywhere you just use Any? (including arrays)

@Ph0enixKM
Copy link
Member Author

Yeah.. I've been thinking about this... if this is a good idea to introduce such type. TypeScript has done it because JS enforced it. Aaaand... in any real project you're advised not to use it. So this was a proposition that would not lead people to bad patterns. If you want to use Any type - then just don't specify any type. What do you think?

@Ph0enixKM
Copy link
Member Author

How about we add generics instead.

fn foo<T>(array: [T]) {

}

@Ph0enixKM Ph0enixKM changed the title [Feature] Add an array generic type [] [Feature] Add an array generic type Aug 8, 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