View Single Post
Old 09 June 2016, 12:30   #9
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,403
Yep, that's where pointers are a better choice. In your first example it was an array, which can easily be shared along with its index (i) to enable the statement to use any instance within that array. If you're talking about different variables entirely and not just different instances within an array, you either need to share them all or use pointers. That example you just posted would still work, but copying newtypes can be slow if they're big, and the statement works with a copy (TestVar), not the original data (Var1 or Var2).

Like I said, if sharing pointers works for you, by all means go for it. It's just more "correct" to pass it as an argument to the statement as in Cylon's example.
Daedalus is online now  
 
Page generated in 0.04091 seconds with 11 queries