-
Notifications
You must be signed in to change notification settings - Fork 64
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
[WIP] AnyOf
Operator
#75
Comments
Isn't your binary operator basically the |
@Echo-8-ERA It is just like the |
I think the usage your This could be resolved by leaving
and extended to any IEnumerable(Of T):
See my comment here. |
Using |
@AdamSpeight2008 Of course, but the idea is that the pattern can be extended very simply:
|
@zspitz I was thinking of an type the did represent Bounds / Limits. It could implement |
This is already possible:
Same for:
|
@tverweij
Presumably you mean:
{GetType(T0), GetType(T1), GetType(T2)}.Contains(obj.GetType)
But this is not quite the same. If `obj.GetType` represents a type which inherits or implements `T0`, then `TypeOf obj Is T0` would evaluate to `True`, even though `obj.GetType = GetType(T0)` would evaluate to `False`. Similarly, `TypeOf obj Is AnyOf {T0, T1, T2}` would also evaluate to `True` if `obj.GetType` would inherit/implement any of `T0`, `T1`, or `T2`.
…________________________________
From: Theo Verweij <notifications@github.com>
Sent: Thursday, November 30, 2017 2:05 PM
To: dotnet/vblang
Cc: Zev Spitz; Mention
Subject: Re: [dotnet/vblang] [WIP] `AnyOf` Operator (#75)
@AdamSpeight2008<https://github.com/adamspeight2008>
TypeOf obj Is AnyOf { T0, T1, T2 ... }
TypeOf obj IsNot AnyOf { T0, T1, T2 ... }
This is already possible:
{T0.GetType, T1.GetType, T2.Gettype, ...}.contains(obj.GetType)
Not {T0.GetType, T1.GetType, T2.Gettype, ...}.contains(obj.GetType)
Same for:
previousWasClass = ( part.Kind = SymbolDisplayPartKind.ClassName ) OrElse
( part.Kind = SymbolDisplayPartKind.InterfaceName ) OrElse
( part.Kind = SymbolDisplayPartKind.StructName )
{SymbolDisplayPartKind.ClassName,
SymbolDisplayPartKind.InterfaceName,
SymbolDisplayPartKind.StructName}.contains(part.Kind)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#75 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AATDZln8azaY1DK40jU6nByWnT-thgM0ks5s7rY6gaJpZM4Nd-oI>.
|
AnyOf
OperatorThis is a generalisation of Proposal #23 to allow other usage cases.
The
AnyOf
operator as two modes of usage, as a :=left AnyOf right
AnyOf right
Binary Operator
This is provides the equivalent of an
=
against a single instance and collection of instance, of some type.Example Usage
Consider the following code., where we are checking the
part.Kind
is one of a set of values.Exisiting
What if we express that in a more operator like form.
Proposed
The code produced by both are functionally equivalent
Today this functionality (not syntax) via extension method
Unary Operator
The primary usage target of this prefix is in
TypeOf obj Is ...
expressions.Existing
Proposed
Implementation
The compiler treats them as syntactic sugar for the exist code. Just that we let the compiler build the underlying expression itself. It then could choose to implement the expression using the operators
=
and<>
or if the object isIComparable/IComparable(Of T)
viao.ComparedTo( x ) = 0
orEqualTo( )
.The text was updated successfully, but these errors were encountered: