Confusion over passing by reference vs passing by value
#10
(06-19-2022, 04:18 PM)DSMan195276 Wrote: Unfortunately a lot of cases involving pass-by-value don't work correctly. The specific one you ran into I made a GitHub issue about a couple days ago:

https://github.com/QB64-Phoenix-Edition/...issues/118

Quote:How the copy happens depends on what kind of array it is - for most arrays the backing buffer can just be copied directly, for variable length strings the qbs objects need to be copied individually.

Also not as one sentence.

Code: (Select All)
Print
satz3() = "SagNiemalsNie!"
Satztest3 (satz3()) '!! Damit hat der Compiler Probleme
Print "Wert des Feldes von satz3 nach der Subroutine: ", satz3()

End


Sub Zahlentest (y As Integer)
  y = y + 1
End Sub

Sub Satztest (b As String)
  b = b + " von QB64!"
End Sub

Sub Satztest2 (feld() As String)
  feld() = "Hallo, Donald Duck!"
End Sub

Sub Satztest3 (feld() As String)
  feld() = feld() + "DonaldDuck"
End Sub
Reply


Messages In This Thread
RE: Confusion over passing by reference vs passing by value - by Kernelpanic - 06-19-2022, 06:01 PM



Users browsing this thread: 3 Guest(s)