LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
mishklyar

Enable "dynamic dispatch" for references to LV classes.

Status: Declined

Any idea that has received less than 4 kudos within 4 years after posting will be automatically declined.

  Why?

- To implement OO design patterns.

_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


5 Comments
Daklu
Active Participant
Can you be more specific?
mishklyar
Member

Recently I was inspired by the GOF book, and tried to implement "Observer" pattern in Labview.

Very fast I discovered that it possible, but the overhead is VERY large.This is because labview doesn't

has "dynamic" dispatch for references to classes.For example you have "Parent" class, and derived "Child_1"

and "Child_2" class.We have now dynamic dispatch, but for passing "by value" only. It's mean that it

impossible to make an array of references to "Parent",  and insert into it the reference to "Child_1", or "Child_2".

IMHO this makes use of Labview classes very limited.

   About other possibilities that I thought about: one can always create array of references to VI's,and

use "Call by reference".But then we go back - this is just a C - style programming (array of pointers to functions).

  I don't mention here using "variant" datatype to implement design patterns - the overhead of "cases" and

"castings" is big -  and actually destroys the OO paradigm.

_________________________________________________________________________________________________
LV 8.2 at Windows & Linux


DJed
Member
We do not support "hidden" dynamic dispatch for references to classes, but one can always dereference a reference with the IPE structure and then dynamically dispatch on the class, with the class being processed "inplace".  One can create an array of References to parent and indeed insert child references into the array, although upcasting may need to be done.temp.jpg  See the image for an example of an array.
DJed
Member

Sorry, here's a bigger copy of the image.  Note that we can create, insert, and index into the array of base class references.  Once you index, either call static methods without dereferencing (we will auto downcast for you) or dereference with the In-Place Element Structure and call any appropriate methods.

 

temp.jpg

Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 4 kudos within 4 years after posting will be automatically declined.