Skip to content

"Unsafe" keyword #67

@mansellan

Description

@mansellan

Credit: this idea is entirely inspired by @fafalone and Niya from this VBF thread - https://www.vbforums.com/showthread.php?890181-TwinBasic&p=5607387&viewfull=1#post5607387

VB6 developers have devised incredible ways of extending what the language can do over the years, using (amongst other things) assembly thunks and direct pointer manipulations. These can all be directly applied to twinBASIC, except for patches to the VB6 runtime internals, which are obviously not supportable. Such advanced techniques step outside the normal safety guarantees that VB6 provides for "normal" code - checking for array bounds, null reference accesses etc. Regardless, such code is valid VB6 and must be supported unmodified by twinBASIC for backwards compatibility.

However, twinBASIC has the opportunity in the future to provide easier ways to achieve many of these capabilities. Raw pointers might be allowed natively. Instead of assembly thunks, we could have inline assembly (or C?)*

My proposal is that if new, "dangerous" features are added, it makes sense to require users opt into them. I propose that a new syntax be added:

Begin Unsafe
   ' Here be dragons...
End Unsafe

C# (although not VB.Net) has a similar concept - if you want to step outside of managed code you can, but you need to opt in with an unsafe block.

* Re inline C... which version? which compiler? It's a quagmire. Comments invited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions