jpo Posted April 18, 2022 Report Share Posted April 18, 2022 Does a Labview vi pass is variable values bu value or by reference? J Quote Link to comment
ak_nz Posted April 18, 2022 Report Share Posted April 18, 2022 If you mean how data is passed via the connector pane - it is all passed by value from a logical stand-point. That includes references, so you get a copy of the reference number in the VI, but it points to the same memory location. I say "logical stand-point" as there are some instances where the compiler will get clever and optimize the call (or places where you have specified it such as sub-routine). However, this doesn't affect how you as a programmer can view the behavior. Quote Link to comment
infinitenothing Posted April 19, 2022 Report Share Posted April 19, 2022 Why do you ask? You don't have to worry about buffer overruns if that's the sort of thing you're concerned with. Quote Link to comment
Rolf Kalbermatter Posted April 21, 2022 Report Share Posted April 21, 2022 (edited) Technically it is all passed around by pointer, which is synonymous to by reference. Logically that makes no difference whatsoever as it all happens under the hood. Data going into a subVI through the connector into a control is consumed by that subVI and considered to be private to the VI. If LabVIEW needs that data somewhere else, it will make a copy, but it has optimizing measures in place that may schedule different functions consuming the same data in a way that they can not stomp on each others data. Data coming through an indicator out of a subVI is from that point owned by the caller and the VI better doesn't try to change it after the fact. For LabVIEW VIs that is not a possibility at all as LabVIEW takes care of that. For data returned from external code through a Call Library Node, it is a grave violation of the LabVIEW memory management contract to try to modify the data in the background once the Call Library Node call has returned control to the diagram. LabVIEW is a managed environment just like .Net but has different management rules. As far as LabVIEW diagrams are concerned there is virtually no way to violate those rules since the dataflow determines everything. If you interface to external code then you could violate that management contract in the external code but doing so is equivalent to placing a bomb in your PC! 💣 Edited April 21, 2022 by Rolf Kalbermatter 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.