-
Notifications
You must be signed in to change notification settings - Fork 392
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
Difference types #1253
Comments
There is a draft RFC for negation types: luau-lang/rfcs#29. Typically, this would mean you could write your example as So the operator you're proposing here would cover a different use case, I just wanted to point out that if the negation type RFC was able to test negated structural types, it would cover your use case as well. Also, it doesn't look like there are any type operations that could be mistaken for value operations, and I think that's because of casting; it happens inside expressions that execute at runtime. -- what could this mean?
local a = b :: T / U
-- it could be one of:
local a = (b :: T) / U
local a = b :: (T / U) Perhaps you could use the symbol set theory/Wikipedia uses, the backslash |
This design looks a lot like And yeah, the design conflicts with |
I did not consider the fact that types appear in expressions, you're correct. I agree with the backslash idea, actually like it a bit more.
100% plausible, I'm not very well vested in TS. |
Going to close this. https://github.com/luau-lang/rfcs will be the right place to submit such a feature request. |
Problem
Consider this:
It's possible to create a type like
M
without writing the property names individually.But it's not possible to create a type like
M
which excludes properties from another type.Use case
You have an Instance which has many objects in it. You want to use the Instance as a dictionary, where you can use e.g.
part.Decal
and use the child decal. This is certainly doable!Now you want to make a function which returns the
Holder
type.But you don't want your function's consumer to have access to irrelevant methods such as
GetChildren
andName
on theHolder
type. This is where a difference of sets comes in place (coloured area):So we want to get everything from
Holder
and remove everything fromPart
on it. This could look something like thisAnd boom! Now we can return
Holder
and we won't see anything fromPart
.P.S. I use
/
instead of-
as the suggested syntax, because a minus looks awkward to me, but it's definitely not the only possible way!The text was updated successfully, but these errors were encountered: