Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Array out of passing arrays... Pete 2 408 09-22-2025, 08:53 PM
Last Post: ahenry3068
  Call by reference / value Kernelpanic 3 910 11-28-2023, 03:41 AM
Last Post: TerryRitchie
  Variable as a reference or value to a function Kernelpanic 22 4,264 08-08-2022, 07:41 PM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)