Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does specifying the OutAttribute on ByRef internal methods currently do anything?

Tags:

vb.net

out

byref

VB.NET doesn't have out parameters, but you can specify <Out()> ByRef on COM and P/Invoke methods to get the same effect for external methods.

Does specifying the same on internal methods (i.e. methods only called by .NET code) actually help the Jitter (or VB.NET compiler)? Or is it currently only useful as a programmer note.

Is it possible it could be used in a future Jitter, or is this attribute lost when compiling?

like image 794
Mark Hurd Avatar asked Jul 19 '11 08:07

Mark Hurd


1 Answers

I've confirmed a VB.NET <Out()> does cause a C# client to require out arguments, so it does seem to be effectively the same.

Also a C# client passes in its arguments with current values into the method, but that's not surprising because, unlike the COM or P/Invoke cases, there's no marshalling to do. (And C# won't allow a property to be set by an out argument directly, so there doesn't seem to be a way to see if C# would optimise away a previous unneeded assignment.)

So it seems the answer is it does help possible future C# clients use the code, and if the jitter ever adjusts the C# equivalent, it would do the same here. Though because languages like VB exist, it can't do much because they don't respect the Out attribute themselves.

like image 180
Mark Hurd Avatar answered Sep 23 '22 13:09

Mark Hurd