-
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
[Proposal] Less verbose null checks #578
Comments
You can't elide the |
|
Also, the expression |
Or you could just define the Option Strict On
Imports System
Public MustInherit Class MyBaseClass
Public Shared Operator IsTrue(ByVal obj As MyBaseClass) As Boolean
Return obj IsNot Nothing
End Operator
Public Shared Operator IsFalse(ByVal obj As MyBaseClass) As Boolean
Return obj is Nothing
End Operator
End Class
Public Class MyChildClass
Inherits MyBaseClass
Public Sub New()
End Sub
End Class
Public Class Program
Public Shared Sub Main(ByVal ParamArray Args As String())
Dim Foo, Bar As MyChildClass
Foo = New MyChildClass()
Bar = Nothing
If Foo Then
Console.WriteLine("Foo is Not Nothing!")
Else
Console.WriteLine("Foo is Nothing!")
End If
If Bar Then
Console.WriteLine("Bar is Not Nothing!")
Else
Console.WriteLine("Bar is Nothing!")
End If
End Sub
End Class |
@Echo-8-ERA |
The compiler must be edited and maintained by people. You cannot expect one team to serve the world. |
While I occasionally like the idea of a As for implicitly converting null references to I would rather look for ways to prevent null references from getting into my code in the first place (looking jealously at C#'s new nullable reference types and that proposed shorthand for throwing an exception when an argument is null) than try to deal with those null references every time I access an object. |
You can't, and you shouldn't. We even make value types nullable, as null provides a very useful state, a flag that we need most of the time. More important: readability is not only about English words, but also about the bulk of the code you see. All human languages care most for eloquence of the sentence, not just being in the correct syntax or just give a meaning. I can write 100 words to give the same meaning of a 3 words. |
They are paid for that. And a compiler will not be used by all the globe, unless it services them well. In fact you show a practical experiment about what happened when C# tllo all the attention and VB got neglected over years! Companies asked for C# developers, and most of VB developers had to switch to it. You can't depend on a compiler that doesn't fulfil your needs as soon as you need them. |
Note that the C# equivalent proposal, dotnet/csharplang#2883, seems to have a bit of traction, but given the “no new development” strategy, I don’t have much hope for this in VB. If C# doesn’t get it, then, “it’s not needed”, and if C# does get it, then, “it’s an advanced feature, use c#”. |
@jrmoreno1 |
"I am sharing these ideas to be a part of any new implementation of VB.NET" "I hope someday I can fork VB and implement them myself." |
@tverweij |
My last message here, to be complete. Our implementation will evolve, but we don't use these sites anymore - we looked at the existing issues when we started, took the best out of that and now we are evolving the language our own way, separate from Microsoft, even evolving away from .Net to native AOT on each platform (while .Net (Core) stays 100% supported) |
@tverweij |
vb is verbose language. Don't make it as another cryptic C# |
Can't we writ this statement:
just as:
Or at least:
I am using
option strict of
, so, again, why can't an object converted to a Boolean in a condition context?Or at least:
and of course, I prefer
pop?.IsOpen = False
the most.The text was updated successfully, but these errors were encountered: