Broken Ptr syntax

Testing the functionality of pointers, the syntax given in your documentation fails to compile:

Dim t As Ptr(Of String)
t = AddressOf “Some Literal String”

The error is that t is expecting a ^String.

Also is it possible to extend the Item property of the Ptr class to index pointer arrays?

Curious. it does not work with literals, but it does work with a String variable. This could be s-designed, and a side effect of how the constant string literal does not exist as an actual String class instance at tis stage. But i’ll bring it up with the team for review.

this works:

    Dim t As Ptr(Of String)
    't = AddressOf “Some Literal String”    
    Dim s = “Some Literal String”
    t = AddressOf s

FWIW, the same happens in C#

		string s;
		string* x = &s;
		string* y = "text"; // E62 Type mismatch, cannot assign "String" to "String*"

Oddly tough, in mercury this copmpiles without enablig Unsafe code; in C# it doesn’t i’ll log this too.

Good idea, yes.

Logged as bugs://E25472. for pointers of string literals

Logged as bugs://E25473. for Mercury not honoring/requiring “allow unsafe code”

Logged as bugs://E25474. for the pointer arrays

Thanks for the response. I’m glad your team has implemented pointers in your VB framework. I created a NuGet package years ago called VBUnmanaged. I had a similar concept in mind with a Ptr class. Are delegate function pointers functional at the moment in both directions?


I’m not aware of any problems with them, so I’d like to say “yes”. But JIC, can you elaborate on what you mean by “both directions”?

Meaning, we are able to marshal data either to or from a native process.

Oh, like that. i believe so, yes. P/Invoke isn’t my area of expertise, i suggest to give it a try :wink:

bugs://E25473 was closed as fixed.

bugs://E25474 was closed as fixed.

Good idea, yes.

Note since vb uses () for indexing, s(15) = s(15) + “” is it.

1 Like

bugs://E25474 was reopened. << this for documentation. the feature is there.

1 Like

FWIW, these fixes will not be in today’s upcoming build, as that’s already 90% done

bugs://E25472 was closed as fixed.