-
-
Notifications
You must be signed in to change notification settings - Fork 252
Add docs and syntax lookup for scoped polymorphic types #693
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
Add docs and syntax lookup for scoped polymorphic types #693
Conversation
a5d416e
to
9207f7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
Looking good! One question I had if it would be better to call it "locally scoped polymorphic types" vs "globally scoped polymorphic types" (instead of "normal polymorphic "?) Would make more sense to me, but if everyone thinks this is fine, we can go with this ofc. |
More precise, though longer. |
i had some more thoughts about it and will post another suggestion later today when i am at a computer. |
According to the types docs, we currently call For symmetry, I'd propose to call Instead of "normal type parameter", I'd probably call it "common type parameter". |
That terminology might be inferred to describe the difference between |
So what name is it now? Or should we do a survey on the forum? |
I have validated "scoped polymorphic types". Considering another choice needs validation. Not sure there are other suggestions so far that can be bought forward. |
In the context of programming languages, local polymorphic types with restrictions refer to type parameters that are scoped within a specific block or context, and can only be used within that scope. This is in contrast to ordinary polymorphic types, where the type parameters are globally defined and can be used across different parts of the codebase. Let's consider a hypothetical programming language that supports both local and ordinary polymorphic types for a clearer understanding. Example of Local Polymorphic Types with Restrictions:
In the above example, the function Use Case for Local Polymorphic Types: In the example above, the Comparison to Ordinary Polymorphic Types: For example:
In this case, the type argument for Ordinary polymorphic types are more suitable when you want consistency in type resolution across different parts of the codebase or when you want to enforce a specific type argument throughout the program. In summary, local polymorphic types with restrictions allow for localized type inference and flexibility within specific scopes, whereas ordinary polymorphic types provide global consistency for type resolution across the entire codebase. The choice between them depends on the specific requirements and design of the program. |
I have misspelled "restrict," so the answer is for TS, but the concept seems to come across no problem. |
I personally don't have strong preferences on local vs scoped. |
@ryyppy are you fine with "local polymorphic types"? |
After back and forth let's settle for "scoped polymorphic types" since this seems to be the most liked version so far. |
based on https://gist.github.com/cristianoc/71e14bee170c7b3fec3e50ddb6963254
fixes #304