mirror of
https://github.com/luau-lang/rfcs.git
synced 2025-04-20 03:44:05 +01:00
type functions can call other type functions but not regular functions
This commit is contained in:
parent
8a7903f906
commit
e1005b27a6
1 changed files with 3 additions and 0 deletions
|
@ -37,6 +37,9 @@ type Person = {
|
||||||
|
|
||||||
type ty = rawget<Person, "name"> -- ty = string
|
type ty = rawget<Person, "name"> -- ty = string
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Type functions operate on two stages: type analysis and runtime. They are _called_ at the type level of Luau, but _runs_ at runtime to operate on the values of types (such as the arguments of the function). For this reason, type functions are declared using parenthesis and invoked using angle brackets. Moreover, every type functions will be part of and ran within the same scope (rlly? what if they are defined in a function) to allow type functions to call other type functions. We will not (and probably never) allow type functions to call regular functions for the sake of sandboxing runtime and analysis time.
|
||||||
|
|
||||||
To allow Luau developers to modify the runtime values of types in type functions, this RFC proposes introducing a new userdata called `lType`. An `lType` object is a runtime representation of all types within the program and provides a basic set of library methods that can be used to modify types. As such, under the hood, each argument of a type function is serialized into a userdata called `lType`. Moreover, they are *only accessible within type functions* and are *not a runtime type for other use cases than type functions*.
|
To allow Luau developers to modify the runtime values of types in type functions, this RFC proposes introducing a new userdata called `lType`. An `lType` object is a runtime representation of all types within the program and provides a basic set of library methods that can be used to modify types. As such, under the hood, each argument of a type function is serialized into a userdata called `lType`. Moreover, they are *only accessible within type functions* and are *not a runtime type for other use cases than type functions*.
|
||||||
|
|
||||||
<details><summary>lType library methods (dropdown)</summary>
|
<details><summary>lType library methods (dropdown)</summary>
|
||||||
|
|
Loading…
Add table
Reference in a new issue