-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RFC: Support for thread and buffer Types in User-Defined Type Functio…
…ns (#77)
- Loading branch information
1 parent
03608c7
commit 5c26c39
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
docs/support-for-thread-and-buffer-types-in-user-defined-type-functions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Support for thread and buffer Types in User-Defined Type Functions | ||
|
||
## Summary | ||
|
||
Add support for 'thread' and 'buffer' primitive types, omitted from original user-defined type function RFC. | ||
|
||
## Motivation | ||
|
||
While more rarely used than 'string' or 'number', 'thread' and 'buffer' are perfectly valid primitive types already supported by Luau typechecking engine, so should be included in user-defined type function API. | ||
|
||
Developers are already hitting this limitation and there's no specific reason to exclude these types. | ||
|
||
## Design | ||
|
||
We propose two new library properties and two new type tags. | ||
|
||
No methods are added for types with these new tags. | ||
|
||
### Update `types` Library | ||
|
||
| Library Properties | Type | Description | | ||
| ------------- | ------------- | ------------- | | ||
| `thread` | `type` | an immutable instance of the built-in type `thread` | | ||
| `buffer` | `type` | an immutable instance of the built-in type `buffer` | | ||
|
||
### Update `type` Instance | ||
|
||
| Instance Properties | Type | Description | | ||
| ------------- | ------------- | ------------- | | ||
| `tag` | `"nil" \| "unknown" \| "never" \| "any" \| "boolean" \| "number" \| "string" \| "singleton" \| "negation" \| "union" \| "intersection" \| "table" \| "function" \| "class" \| "thread" \| "buffer"` | an immutable property holding this type's tag | | ||
|
||
## Drawback | ||
|
||
Unclear if this proposal has any drawbacks. |