From a22eb205dd7fd805cfaabc40c64ace9462cd5917 Mon Sep 17 00:00:00 2001 From: Junseo Yoo Date: Tue, 11 Jun 2024 15:33:33 -0700 Subject: [PATCH 1/7] Added a note about how this type operator doesn't work with class types --- docs/rawget-type-operator.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/rawget-type-operator.md b/docs/rawget-type-operator.md index 4b37006..4e2c778 100644 --- a/docs/rawget-type-operator.md +++ b/docs/rawget-type-operator.md @@ -36,6 +36,8 @@ local key = "property" type age = rawget -- Error message: Second argument to rawget is not a valid index type; Unknown type 'key' ``` +Note: `rawget` type operator does not work on class types because they do not have direct fields that can be looked up without invoking its metamethod. + The implementation effort for this type operator is very minimal. Since the `rawget` type operator functions similarly to the `index` type operator, we can reuse the functions already used to implement the `index` type operator. ## Drawbacks From 70db7708a32425212d9d265b98c9e27135f1d877 Mon Sep 17 00:00:00 2001 From: Junseo Yoo <59751754+joonyoo181@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:28:53 -0700 Subject: [PATCH 2/7] Rephrased the summary Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com> --- docs/rawget-type-operator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rawget-type-operator.md b/docs/rawget-type-operator.md index 4e2c778..94d9aad 100644 --- a/docs/rawget-type-operator.md +++ b/docs/rawget-type-operator.md @@ -2,7 +2,7 @@ ## Summary -This RFC proposes the addition on one type operator, `rawget`, which can be used to look up a specific property of another type *without* invoking the `__index` metamethod. +This RFC proposes the addition of a new type operator, `rawget`, which can be used to look up a specific property of a table type *without* invoking the `__index` metamethod. ## Motivation From b4980e0435cadb29b0d0a1e0bfe1c1eda43990cf Mon Sep 17 00:00:00 2001 From: Junseo Yoo <59751754+joonyoo181@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:31:33 -0700 Subject: [PATCH 3/7] Redirect users to open-source Luau global functions Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com> --- docs/rawget-type-operator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rawget-type-operator.md b/docs/rawget-type-operator.md index 94d9aad..4540b83 100644 --- a/docs/rawget-type-operator.md +++ b/docs/rawget-type-operator.md @@ -6,7 +6,7 @@ This RFC proposes the addition of a new type operator, `rawget`, which can be us ## Motivation -Given that `rawget` is a built-in runtime operator in the language ([rawget Lua Globals](https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#rawget)), it feels natural for there to be a version of this as a type operator. As such, the main motivation behind this feature is to close out holes in Luau's type families and allow Luau developers to be more expressive writing typed code: +Given that `rawget` is a built-in runtime operator in the language ([rawget in Luau Global functions](https://luau-lang.org/library#global-functions)), it feels natural for there to be a version of this as a type operator. As such, the main motivation behind this feature is to close out holes in Luau's type families and allow Luau developers to be more expressive writing typed code: ```luau local prop: rawget = rawget(someTy, someProp) From 2cd9574abb409bf8e730187fae012223c656ef2f Mon Sep 17 00:00:00 2001 From: Junseo Yoo <59751754+joonyoo181@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:32:08 -0700 Subject: [PATCH 4/7] reword "runtime pair" to counterpart and update the link Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com> --- docs/rawget-type-operator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rawget-type-operator.md b/docs/rawget-type-operator.md index 4540b83..75ccbe2 100644 --- a/docs/rawget-type-operator.md +++ b/docs/rawget-type-operator.md @@ -14,7 +14,7 @@ local prop: rawget = rawget(someTy, someProp) ## Design -The functionality of `rawget` type operator behaves the same as its [runtime pair](https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#rawget): provide a way to look up a specific property of a type without invoking the `__index` metamethod. +The functionality of `rawget` type operator behaves the same as its [runtime counterpart](https://luau-lang.org/library#global-functions): provide a way to look up a specific property of a table type without invoking the `__index` metamethod. ```luau local var1 = { From 960a1f7a4a9d25e525aa4fa83231d49876dd3d88 Mon Sep 17 00:00:00 2001 From: Junseo Yoo <59751754+joonyoo181@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:32:41 -0700 Subject: [PATCH 5/7] grammar fix: "interactions" -> "interaction" Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com> --- docs/rawget-type-operator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rawget-type-operator.md b/docs/rawget-type-operator.md index 75ccbe2..8bdffd0 100644 --- a/docs/rawget-type-operator.md +++ b/docs/rawget-type-operator.md @@ -44,7 +44,7 @@ The implementation effort for this type operator is very minimal. Since the `raw There aren't appreciable drawbacks. One possible drawback is the increase in the size of the codebase, which may complicate maintenance. However, this is not expected to be a major drawback since the code for `index` type operators already exists. By reusing the code, it is even fair to say that there will be less than 50 lines of code needed to implement this type operator. -Another drawback can come from the extra knowledge a user may need in order to use this type operator. For example, users will need to know the inner workings of types and how different operations interact with them (for instance, how `index` interacts with metatables that have the `__index` metamethod). However, there are documentations that outline each interactions, and thus this drawback does not seem to pose an issue. +Another drawback can come from the extra knowledge a user may need in order to use this type operator. For example, users will need to know the inner workings of types and how different operations interact with them (for instance, how `index` interacts with metatables that have the `__index` metamethod). However, there are documentations that outline each interaction, and thus this drawback does not seem to pose an issue. ## Alternatives From 2126e5c0d2c9388b46c6bb0bb15be32edc18d323 Mon Sep 17 00:00:00 2001 From: Junseo Yoo <59751754+joonyoo181@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:11:37 -0700 Subject: [PATCH 6/7] Revised wording for motivation section Co-authored-by: aaron --- docs/rawget-type-operator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rawget-type-operator.md b/docs/rawget-type-operator.md index 8bdffd0..1c4be96 100644 --- a/docs/rawget-type-operator.md +++ b/docs/rawget-type-operator.md @@ -6,7 +6,7 @@ This RFC proposes the addition of a new type operator, `rawget`, which can be us ## Motivation -Given that `rawget` is a built-in runtime operator in the language ([rawget in Luau Global functions](https://luau-lang.org/library#global-functions)), it feels natural for there to be a version of this as a type operator. As such, the main motivation behind this feature is to close out holes in Luau's type families and allow Luau developers to be more expressive writing typed code: +Currently, `rawget` is a built-in runtime operator in the language ([rawget in Luau Global functions](https://luau-lang.org/library#global-functions)) that is missing a corresponding type operator that captures its behavior. This RFC seeks to address this hole in the type system by providing a builtin type operator for `rawget` that will allow Luau developers to express more accurate types in their code: ```luau local prop: rawget = rawget(someTy, someProp) From fd7fab8c3574d2c3a98a65d1e63ab7e8a75481c4 Mon Sep 17 00:00:00 2001 From: Junseo Yoo <59751754+joonyoo181@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:12:07 -0700 Subject: [PATCH 7/7] Added an article and broke up a sentence into two Co-authored-by: aaron --- docs/rawget-type-operator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rawget-type-operator.md b/docs/rawget-type-operator.md index 1c4be96..1e0c180 100644 --- a/docs/rawget-type-operator.md +++ b/docs/rawget-type-operator.md @@ -14,7 +14,7 @@ local prop: rawget = rawget(someTy, someProp) ## Design -The functionality of `rawget` type operator behaves the same as its [runtime counterpart](https://luau-lang.org/library#global-functions): provide a way to look up a specific property of a table type without invoking the `__index` metamethod. +The functionality of the `rawget` type operator behaves the same as its [runtime counterpart](https://luau-lang.org/library#global-functions). Namely, it provide a way to look up a specific property of a table type without invoking the `__index` metamethod. ```luau local var1 = {