Req5: unsafe and pointer support

[This post is part of a series, "wish-list for future versions of VB"]


IDEA: "unsafe" and pointer support. VB should support unsafe programming, like C#, with pointers and all that.

SCENARIO: Pointer support is useful for people who write marshallers and operating systems and device-drivers. It's also useful for people who want to operate on memory-buffers that they get from the operate system but without any copying involved.


Provisional evaluation from VB team: None of them feel like they're mainstream .NETish or VBish (or C#ish even). It would be a shame to twist the language as much as this would require, just to let it cover a small additional niche.

Comments (4)

  1. Kevin Ryall says:

    I have to admit that I have no desire for this – it seems like it wouldn’t add to the language. I don’t use pointers in C# either, it’s easier to use C++ in the rare case where I need to do some low-level programming.  

  2. Héctor says:

    This is something I’ve been asking for since VB 8.0.

    Adding unsafe code support would shorted the differences with C# greatly and allow for a lot of C# code to be ported over to VB.

    If Visual Studio would be able to nicely manage C# and VB code together inside the same project I’d have less interest for this tho.

  3. Why would supporting pointers and "unsafe" programming twist the VB language? Of course it would require resources to implement functionality in VB.NET to support pointers but I don’t equate this to twisting the language.

    The following, including whatever VB construct is required to dereference pointers, don’t appear to twist the language (they just extend VB’s syntax):


    End Unsafe


    End Fixed

    Definitely the compiler has to do more work;  but so would it when you introduce new features such as generics, the yield statement, etc.

    I agree that the number of uses or support for pointers in general programming is little but I have had to program against exported C functions recently and even though my language of choice is VB I was forced to use C# and contend with even more unfamiliarity. Implementing the handful of constructs above would have made me stay comfortable and productive in VB rather than having to fight C#’s unfamiliar language constructs.

    I can say that providing support for pointers, etc., simply makes VB more powerful and could draw a more diverse crowd (and respectability) to VB!

    All we’re talking about here are a few syntax constructs – and implementation – to enable support for pointers, etc.

  4. Theo Verweij says:

    Since when are pointers a niche?

    Pointers can cause problems, but they are also very powerful. Even VB6 had a limited (undocumented) way of using pointers.

    The fact that most VB programmers have no need for pointers, is caused by the fact that everyone who needs them do not want to use VB, just because VB doesn’t support pointers.

Skip to main content