Scout RFC: is keyword.#204
Conversation
|
I personally want a more powerful feature to introspect types on runtime than this, it seems boring to have yet another way of doing something that can already be done ostensibly + integrating with the class feature. I know the luau team is conflicted with typeof but I really liked it and wish was there was a function that gave more expansive information that is readable on runtime. What I had in mind was something like this and would aim to solve the same problem while integrating with the existing syntax and has similar ergonomics to user defined type functions local ti = typeinfo(x)
if ti.type == "class" and t1.name == "Part" then
end
if ti.type == "table" then
for k, v in ti.members do
end
end
if ti.type == "function" then
for k, v in ti.generics then
end
for k, v in ti.parameters then
end
end |
|
I feel like this RFC could use additional examples in the motivation section. The rest of the RFC is fine, but it could benefit from additional reasons as to why people would rather have |
|
I don't know how I feel about adding new syntax with as many surprising restrictions/gotchas as this. I feel even more uncomfortable with the proposed evaluation semantics. First, Second, the typename resolution rules are unhygienic. Making an exception to the "identifiers fallback to the global namespace if not local" rule is bad enough, but I also want to mention that this prevents users from naming their locals anything that collides with a typename, lest they permanently break the expression: local boolean = true
local result = x is boolean -- impossible to do now, not even forward-declaring an alias can fix thisAll of these ugly warts combined convinces me that this is not worth the added syntax sugar. |
It doesn't! This RFC explains this at this section, in particular.
This RFC covers this. I already said that these two cannot be used together, and you have to explicitly write parentheses around the expression you want to cast or perform a type test, which is what happens if
This is true, but...
I'll add this into the RFC as a wart, but counter it with it not being all that different from globals. Global typenames are no different from global libraries from this point of view. |
|
Would a less magical global This is pretty much exactly what the RFC is proposing, but without the awkward syntax and namespacing rules. I find it surprising that this option isn't even mentioned in the alternatives. |
Rendered.