-
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
Block-scoped Option Statements #117
Comments
Please yes. At present, I sometimes maintain a partial class file with Option Strict Off at the top for the occasional late-binding scenario (which VB was famous for until...). Method scoping would be superior, though - almost as good as |
Function F0()
Option Strict Off
Imports System.Text
End Function This currently parses but produces an error
Function F1()
Local Option Strict Off
Local Imports System.Text
End Function We could introduce a new contextual keyword
Function F2()
Using Option Strict Off
Using Imports System.Text
End Using
End Using
End Function
Function F3()
Using Option Strict Off, Imports System.Text
End Using
End Function @AnthonyDGreen |
@AdamSpeight2008 How is that highly likely a breaking change? The statements aren't allowed in methods today and then they would be. That's not a breaking change. Re: Namespace scoped Imports, as one former language designer put it "We probably put those in C# because of Java and if we had to do it over again we problem wouldn't". They add a lot of complexity everywhere (compiler, IDE) for not a whole lot of benefit. |
The VB LDM looked at this issue on August 23rd and would like this proposal to go further. We also would like method-scoped |
Would this allow VB to support unchecked like in C#? If not where is a good place to discuss that? |
#33 seems orphaned but I think getting it revived as part of this would be welcome. |
FYI just found out that source level option strict on/off is already possible.
Now in the code you can use "#Disable Warning BC42017, BC42016" to disable option strict and "#Enable Warning BC42017, BC42016" to enable option strict again. By example the following code will compile (but will crash) between those compiler switches:
So I don't think it should be very hard to implement this as:
|
I prefer |
Because sometimes you only need it in that one method. Could potentially address scenario #135.
The text was updated successfully, but these errors were encountered: