-
Notifications
You must be signed in to change notification settings - Fork 66
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
?
as Boolean type char
#148
Comments
I like the usage of |
Class Foo
Public Sub Calls()
End Sub
End Class
Module Test
Sub Main()
' Boolean
Dim success? = Test()
' If Nothing syntax sugar
Dim o As New Foo
Call o?.Calls()
' Nullable
Dim n As Integer? = 5
Call n?.CompareTo(0)
End Sub
End Module @AdamSpeight2008 How would it work with the nullable member access and current If Nothing syntax sugar? Due to the reason of we just using |
I see an ambiguity on |
@xieguigang Initial parsing a type character done. Feature: Boolean TypeCharacter |
Hi, @AdamSpeight2008 because I'm not so familiar to vbc its operation mechanism, so that I can not give too much help on the code implementation, but I think this issue is very similar to the scenario of dynamics Late-bound member access. For example, the Late-bound member access and invocation expressions that using candidate ' we not sure this is a method call from a single type
' or dynamics call from an object
Call obj!.method() Which is very similar to the scenario in current issue: ' we not sure this is a method call from a boolean type
' or method calls from a nullable object
Call obj?.method() There are two possible solution for this disambiguate job, as @AnthonyDGreen has pointed out:
The solution for detects that the statement is a member access from boolean or null-member access, probably could be determined based on the code context: what data type of the parsed identifier it is, this can be solved from the code association between the member access statement and the variable definition. |
The problem here is that I'm not much of a fan of type characters to begin with given that they only apply to the built-in types. |
The
?
character was chosen using for theNullable
structure type currently. And all of the stand along?
type char currently was defined as nullableObject
type, but theObject
is already can beNothing
.In my opinion, the
?
character have some literal meaning like:So proposal, when user define a variable with a stand along
?
character, then it should be defined as aBoolean
variable:The text was updated successfully, but these errors were encountered: